mirror of
https://github.com/unclshura/BlazorOpenApi.git
synced 2025-12-21 09:51:53 +00:00
Compare commits
2 Commits
5faa56c8b8
...
16c5d2e85b
| Author | SHA1 | Date | |
|---|---|---|---|
| 16c5d2e85b | |||
| b8602b8e71 |
@ -7,7 +7,7 @@
|
|||||||
@foreach (var (name, val) in Value.Schemas)
|
@foreach (var (name, val) in Value.Schemas)
|
||||||
{
|
{
|
||||||
<h4>@name</h4>
|
<h4>@name</h4>
|
||||||
<SchemaControl Value="@val"/>
|
<SchemaControl Value="@val" Collapsed="false"/>
|
||||||
}
|
}
|
||||||
</TocMember>
|
</TocMember>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,24 @@
|
|||||||
@if (Value.Type == "array")
|
@if (Value.Type == "array")
|
||||||
{
|
{
|
||||||
<Expander HeaderClass="s-type" Class="s-bg-odd" Title="@ArrayText" Collapsed="@Collapsed">
|
<Expander HeaderClass="s-type" Class="s-bg-odd" Title="@ArrayText" Collapsed="@Collapsed">
|
||||||
|
@if (Value.Items?.Type == "object" && SchemaControl.Resolve(Value.Items, Api)?.Properties != null)
|
||||||
|
{
|
||||||
|
@* Skip one level *@
|
||||||
|
<div class="s-props s-nested">
|
||||||
|
<table class="schema">
|
||||||
|
@foreach (var p in SchemaControl.Resolve(Value.Items, Api)!.Properties)
|
||||||
|
{
|
||||||
|
<SchemaChildControl Value="@p.Value" Title="@p.Key" Required="@IsRequired(p.Key)" />
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
<div class="s-nested">
|
<div class="s-nested">
|
||||||
<SchemaControl Value="@Value.Items" />
|
<SchemaControl Value="@Value.Items" />
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</Expander>
|
</Expander>
|
||||||
}
|
}
|
||||||
else if (Value.Type == "object")
|
else if (Value.Type == "object")
|
||||||
@ -55,6 +70,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public OpenApiDocument? Api { get; set; }
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public OpenApiSchema? Value { get; set; }
|
public OpenApiSchema? Value { get; set; }
|
||||||
[Parameter]
|
[Parameter]
|
||||||
@ -73,11 +90,15 @@
|
|||||||
if (Value?.Type != "array")
|
if (Value?.Type != "array")
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
string arrayType = Value.Items?.Type ?? "";
|
||||||
|
if ( Value.Items?.Type != "array" && Value.Items?.Type != "object")
|
||||||
|
arrayType = Value.Items?.Type ?? "array";
|
||||||
|
|
||||||
var nullable = Value.Nullable ? "?" : "";
|
var nullable = Value.Nullable ? "?" : "";
|
||||||
|
|
||||||
if (Value.MinItems != null || Value.MaxItems != null)
|
if (Value.MinItems != null || Value.MaxItems != null)
|
||||||
return $"array{nullable} [{(Value.MinItems == null ? "" : Value.MinItems.Value)}..{(Value.MaxItems == null ? "" : Value.MaxItems.Value)}]";
|
return $"{arrayType}{nullable} [{(Value.MinItems == null ? "" : Value.MinItems.Value)}..{(Value.MaxItems == null ? "" : Value.MaxItems.Value)}]";
|
||||||
return $"array{nullable} []";
|
return $"{arrayType}{nullable} []";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,15 +19,17 @@
|
|||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
public OpenApiDocument? Api { get; set; }
|
public OpenApiDocument? Api { get; set; }
|
||||||
|
|
||||||
private OpenApiSchema? ResolvedValue
|
private OpenApiSchema? ResolvedValue => Resolve(Value, Api) ?? Value;
|
||||||
|
|
||||||
|
public static OpenApiSchema? Resolve(OpenApiSchema? schema, OpenApiDocument? api)
|
||||||
{
|
{
|
||||||
get
|
if (schema == null)
|
||||||
|
return null;
|
||||||
|
if (schema.Reference != null && api != null)
|
||||||
{
|
{
|
||||||
if (Api == null || Value?.Reference == null )
|
if (api.Components.Schemas.TryGetValue(schema.Reference.Id, out var resolved))
|
||||||
return Value;
|
|
||||||
if (!Api.Components.Schemas.TryGetValue(Value.Reference.Id, out var resolved))
|
|
||||||
return Value;
|
|
||||||
return resolved;
|
return resolved;
|
||||||
}
|
}
|
||||||
|
return schema;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,7 +162,7 @@
|
|||||||
height: fit-content;
|
height: fit-content;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 3px;
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
padding-right: 3px;
|
padding-right: 3px;
|
||||||
@ -314,16 +314,30 @@
|
|||||||
|
|
||||||
.openapi-ui h1 {
|
.openapi-ui h1 {
|
||||||
margin-top: 24px;
|
margin-top: 24px;
|
||||||
|
border-left-width: 5px;
|
||||||
|
border-color: var(--oa-bg-7);
|
||||||
|
padding-left: 5px;
|
||||||
|
margin-bottom: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.openapi-ui h2 {
|
.openapi-ui h2 {
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
color: var(--oa-fg-7);
|
||||||
|
border-bottom-width: 4px;
|
||||||
|
border-color: var(--oa-bg-7);
|
||||||
}
|
}
|
||||||
.openapi-ui h3 {
|
.openapi-ui h3 {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
border-color: var(--oa-bg-7);
|
||||||
}
|
}
|
||||||
.openapi-ui h4 {
|
.openapi-ui h4 {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
border-color: var(--oa-bg-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.openapi-ui .tooltip {
|
.openapi-ui .tooltip {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user