mirror of
https://github.com/unclshura/BlazorOpenApi.git
synced 2025-12-21 09:51:53 +00:00
Compare commits
No commits in common. "16c5d2e85b2d35329d3f0fe23fd45f7c6a8527b8" and "5faa56c8b8c4a9a7cf228056bc7d17e74006fd06" have entirely different histories.
16c5d2e85b
...
5faa56c8b8
@ -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" Collapsed="false"/>
|
<SchemaControl Value="@val"/>
|
||||||
}
|
}
|
||||||
</TocMember>
|
</TocMember>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,24 +5,9 @@
|
|||||||
@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)
|
<div class="s-nested">
|
||||||
{
|
<SchemaControl Value="@Value.Items" />
|
||||||
@* Skip one level *@
|
</div>
|
||||||
<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">
|
|
||||||
<SchemaControl Value="@Value.Items" />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</Expander>
|
</Expander>
|
||||||
}
|
}
|
||||||
else if (Value.Type == "object")
|
else if (Value.Type == "object")
|
||||||
@ -70,8 +55,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[CascadingParameter]
|
|
||||||
public OpenApiDocument? Api { get; set; }
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public OpenApiSchema? Value { get; set; }
|
public OpenApiSchema? Value { get; set; }
|
||||||
[Parameter]
|
[Parameter]
|
||||||
@ -90,15 +73,11 @@
|
|||||||
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 $"{arrayType}{nullable} [{(Value.MinItems == null ? "" : Value.MinItems.Value)}..{(Value.MaxItems == null ? "" : Value.MaxItems.Value)}]";
|
return $"array{nullable} [{(Value.MinItems == null ? "" : Value.MinItems.Value)}..{(Value.MaxItems == null ? "" : Value.MaxItems.Value)}]";
|
||||||
return $"{arrayType}{nullable} []";
|
return $"array{nullable} []";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,17 +19,15 @@
|
|||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
public OpenApiDocument? Api { get; set; }
|
public OpenApiDocument? Api { get; set; }
|
||||||
|
|
||||||
private OpenApiSchema? ResolvedValue => Resolve(Value, Api) ?? Value;
|
private OpenApiSchema? ResolvedValue
|
||||||
|
|
||||||
public static OpenApiSchema? Resolve(OpenApiSchema? schema, OpenApiDocument? api)
|
|
||||||
{
|
{
|
||||||
if (schema == null)
|
get
|
||||||
return null;
|
|
||||||
if (schema.Reference != null && api != null)
|
|
||||||
{
|
{
|
||||||
if (api.Components.Schemas.TryGetValue(schema.Reference.Id, out var resolved))
|
if (Api == null || Value?.Reference == null )
|
||||||
return resolved;
|
return Value;
|
||||||
|
if (!Api.Components.Schemas.TryGetValue(Value.Reference.Id, out var resolved))
|
||||||
|
return Value;
|
||||||
|
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: 3px;
|
border-radius: 5px;
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
padding-right: 3px;
|
padding-right: 3px;
|
||||||
@ -314,30 +314,16 @@
|
|||||||
|
|
||||||
.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