mirror of
https://github.com/unclshura/BlazorOpenApi.git
synced 2025-12-21 09:51:53 +00:00
Request body UI added. Top level objects expanded by default.
This commit is contained in:
parent
c182db2b64
commit
959fef4418
26
BlazorOpenApi/Controls/MediaTypeControl.razor
Normal file
26
BlazorOpenApi/Controls/MediaTypeControl.razor
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@using Microsoft.OpenApi.Models
|
||||||
|
|
||||||
|
@if (Value != null)
|
||||||
|
{
|
||||||
|
<div class="mt-body">
|
||||||
|
<div class="mt-header-text">@Key</div>
|
||||||
|
<SchemaControl Value="@Value.Schema" Collapsed="false"/>
|
||||||
|
<div class="p-body">
|
||||||
|
<ExampleControl Value="@Value.Example" />
|
||||||
|
@if (Value.Examples.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var (n, v) in Value.Examples)
|
||||||
|
{
|
||||||
|
<ExampleControl Example="@v" Name="@n" />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string? Key { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public OpenApiMediaType? Value { get; set; }
|
||||||
|
}
|
||||||
@ -49,6 +49,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<ParametersControl Value="@Value.Parameters"/>
|
<ParametersControl Value="@Value.Parameters"/>
|
||||||
|
<RequestBodyControl Value="@Value.RequestBody"/>
|
||||||
<ResponsesControl Value="@Value.Responses" />
|
<ResponsesControl Value="@Value.Responses" />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
20
BlazorOpenApi/Controls/RequestBodyControl.razor
Normal file
20
BlazorOpenApi/Controls/RequestBodyControl.razor
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@using Microsoft.OpenApi.Models
|
||||||
|
|
||||||
|
@if (Value != null)
|
||||||
|
{
|
||||||
|
<div class="request">
|
||||||
|
<div class="rb-title">Request body</div>
|
||||||
|
<div class="rb-body">
|
||||||
|
<MarkdownControl Value="@Value.Description" />
|
||||||
|
@foreach ( var media in Value.Content)
|
||||||
|
{
|
||||||
|
<MediaTypeControl Key="@media.Key" Value="@media.Value" />
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public OpenApiRequestBody? Value { get; set; }
|
||||||
|
}
|
||||||
@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-body">
|
<div class="p-body">
|
||||||
<SchemaControl Value="@val.Schema" />
|
<SchemaControl Value="@val.Schema" Collapsed="false" />
|
||||||
|
|
||||||
@if (val.Content.Count > 0)
|
@if (val.Content.Count > 0)
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>@k</td>
|
<td>@k</td>
|
||||||
<td>
|
<td>
|
||||||
<SchemaControl Value="@v.Schema" />
|
<SchemaControl Value="@v.Schema" Collapsed="false" />
|
||||||
@if (v.Encoding.Count > 0)
|
@if (v.Encoding.Count > 0)
|
||||||
{
|
{
|
||||||
<table class="r-encoding">
|
<table class="r-encoding">
|
||||||
@ -91,7 +91,7 @@
|
|||||||
{
|
{
|
||||||
<div class="p-name">@key</div>
|
<div class="p-name">@key</div>
|
||||||
<div class="p-body">
|
<div class="p-body">
|
||||||
<SchemaControl Value="@val.Schema"/>
|
<SchemaControl Value="@val.Schema" Collapsed="false" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<td>
|
<td>
|
||||||
@if (Value.Type == "array")
|
@if (Value.Type == "array")
|
||||||
{
|
{
|
||||||
<Expander HeaderClass="s-type" Class="s-bg-odd" Title="@ArrayText">
|
<Expander HeaderClass="s-type" Class="s-bg-odd" Title="@ArrayText" Collapsed="@Collapsed">
|
||||||
<div class="s-nested">
|
<div class="s-nested">
|
||||||
<SchemaControl Value="@Value.Items" />
|
<SchemaControl Value="@Value.Items" />
|
||||||
</div>
|
</div>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
}
|
}
|
||||||
else if (Value.Type == "object")
|
else if (Value.Type == "object")
|
||||||
{
|
{
|
||||||
<Expander HeaderClass="s-type" Class="s-bg-odd" Title="@ObjectText">
|
<Expander HeaderClass="s-type" Class="s-bg-odd" Title="@ObjectText" Collapsed="@Collapsed">
|
||||||
<div class="s-props s-nested">
|
<div class="s-props s-nested">
|
||||||
<table class="schema">
|
<table class="schema">
|
||||||
@foreach (var p in Value.Properties)
|
@foreach (var p in Value.Properties)
|
||||||
@ -63,6 +63,8 @@
|
|||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public bool Required { get; set; }
|
public bool Required { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public bool Collapsed { get; set; } = true;
|
||||||
|
|
||||||
private string TitleText => (string.IsNullOrWhiteSpace(Title) ? Value?.Title : Title) ?? "";
|
private string TitleText => (string.IsNullOrWhiteSpace(Title) ? Value?.Title : Title) ?? "";
|
||||||
|
|
||||||
@ -74,11 +76,10 @@
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
var nullable = Value.Nullable ? "?" : "";
|
var nullable = Value.Nullable ? "?" : "";
|
||||||
var itemsType = $"{Value.Items?.Type ?? "-string-"}{nullable}";
|
|
||||||
|
|
||||||
if (Value.MinItems != null || Value.MaxItems != null)
|
if (Value.MinItems != null || Value.MaxItems != null)
|
||||||
return $"{itemsType} [{(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 $"{itemsType} []";
|
return $"array{nullable} []";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
@if ( ResolvedValue != null )
|
@if ( ResolvedValue != null )
|
||||||
{
|
{
|
||||||
<table class="schema">
|
<table class="schema">
|
||||||
<SchemaChildControl Value="@ResolvedValue" Title="@Title" Required="@Required" />
|
<SchemaChildControl Value="@ResolvedValue" Title="@Title" Required="@Required" Collapsed="@Collapsed"/>
|
||||||
</table>
|
</table>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,6 +15,8 @@
|
|||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public bool Required { get; set; }
|
public bool Required { get; set; }
|
||||||
|
[Parameter]
|
||||||
|
public bool Collapsed { get; set; } = true;
|
||||||
|
|
||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
public OpenApiDocument? Api { get; set; }
|
public OpenApiDocument? Api { get; set; }
|
||||||
|
|||||||
@ -224,7 +224,26 @@
|
|||||||
}
|
}
|
||||||
.r-encoding{}
|
.r-encoding{}
|
||||||
|
|
||||||
.schema {}
|
.request {
|
||||||
|
}
|
||||||
|
|
||||||
|
.rb-body {
|
||||||
|
}
|
||||||
|
.rb-title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt-body {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
.mt-header-text {
|
||||||
|
color: var(--oa-fg-1);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.schema {
|
||||||
|
}
|
||||||
.s-additional-props {}
|
.s-additional-props {}
|
||||||
.s-props {}
|
.s-props {}
|
||||||
.s-title {
|
.s-title {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user