@schemaItem.Model.SchemaId- @(Model.RenderMarkdown(operation.Description)) -
+@server.Url
+ @if (!string.IsNullOrEmpty(server.Description))
+ {
+ (@server.Description)
+ }
+
+ }
+ @path.Name@path.Name
+ @if (path.Deprecated == true)
+ {
+ deprecated
+ }
+
+ + @(Model.RenderMarkdown(operation.Description)) +
+ @if (operation.ExternalDocs?.Url != null) + { + var externalDocsUrl = operation.ExternalDocs.Url.ToString(); + var isElasticDocs = externalDocsUrl.Contains("www.elastic.co/docs") || externalDocsUrl.Contains("elastic.co/guide"); + + @(isElasticDocs ? "Read the reference documentation" : "External documentation") + + } + } + else if (operation.ExternalDocs?.Url != null) + { + var externalDocsUrl = operation.ExternalDocs.Url.ToString(); + var isElasticDocs = externalDocsUrl.Contains("www.elastic.co/docs") || externalDocsUrl.Contains("elastic.co/guide"); + + @(isElasticDocs ? "Read the reference documentation" : "External documentation") + + } + + @if (operation.Security is { Count: > 0 }) + { +@scheme.Key.Name
+ @if (scheme.Value is { Count: > 0 })
+ {
+ (@string.Join(", ", scheme.Value))
+ }
+
+ }
+ }
+ @path.Name@qs.Name
+ @if (qsSchema != null)
+ {
+ @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(CreateSchemaTypeContext(qsSchema)))
+ }
+ @if (qs.Deprecated == true)
+ {
+ deprecated
+ }
+
+ @enumVal
+ }
+ @operation.RequestBody.Description
+@Model.RenderMarkdown(operation.RequestBody.Description)
} - if (content?.Schema?.Properties is not null) + var requestSchema = requestMediaType?.Schema; + if (requestSchema is not null) { -Type: @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(CreateSchemaTypeContext(requestSchema)))
+ } + } + } + + @if (operation.Responses is { Count: > 0 }) + { + var isSingleResponse = operation.Responses.Count == 1; + var singleResponse = isSingleResponse ? operation.Responses.First() : default; + var singleContentType = isSingleResponse && singleResponse.Value?.Content?.Count > 0 + ? singleResponse.Value.Content.First().Key + : null; + +Content-Type: @contentType.Key
Response Type: @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(CreateSchemaTypeContext(responseSchema)))
+ @(await RenderPartialAsync<_PropertyList, PropertyRenderContext>(CreatePropertyContext(arrayItemSchema, $"res-{statusCode}"))) + } + else + { +Response Type: @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(CreateSchemaTypeContext(responseSchema)))
+ } + } } -@property.Key @GetTypeName(property.Value) @header.Key
+ @if (header.Value?.Schema != null)
+ {
+ @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(CreateSchemaTypeContext(header.Value.Schema)))
+ }
+ @if (header.Value?.Required == true)
+ {
+ required
+ }
+ @if (header.Value?.Deprecated == true)
+ {
+ deprecated
+ }
+
+ @example.Value.Value.ToString()
+ }
+ @if (!string.IsNullOrEmpty(example.Value?.ExternalValue))
+ {
+ External example: @example.Value.ExternalValue
+ } +@example.Value.Value.ToString()
+ }
+ @if (!string.IsNullOrEmpty(example.Value?.ExternalValue))
+ {
+ External example: @example.Value.ExternalValue
+ } +{System.Web.HttpUtility.HtmlEncode(defaultStr)}");
+ }
+
+ // String constraints
+ if (schema.MinLength.HasValue)
+ constraints.Add($"min length: {schema.MinLength.Value}");
+ if (schema.MaxLength.HasValue)
+ constraints.Add($"max length: {schema.MaxLength.Value}");
+ if (!string.IsNullOrEmpty(schema.Pattern))
+ constraints.Add($"pattern: {System.Web.HttpUtility.HtmlEncode(schema.Pattern)}");
+
+ // Numeric constraints (these are strings in OpenAPI library)
+ if (!string.IsNullOrEmpty(schema.Minimum))
+ constraints.Add($"min: {schema.Minimum}");
+ if (!string.IsNullOrEmpty(schema.Maximum))
+ constraints.Add($"max: {schema.Maximum}");
+ if (!string.IsNullOrEmpty(schema.ExclusiveMinimum))
+ constraints.Add($"exclusive min: {schema.ExclusiveMinimum}");
+ if (!string.IsNullOrEmpty(schema.ExclusiveMaximum))
+ constraints.Add($"exclusive max: {schema.ExclusiveMaximum}");
+ if (schema.MultipleOf.HasValue)
+ constraints.Add($"multiple of: {schema.MultipleOf.Value}");
+
+ // Array constraints
+ if (schema.MinItems.HasValue)
+ constraints.Add($"min items: {schema.MinItems.Value}");
+ if (schema.MaxItems.HasValue)
+ constraints.Add($"max items: {schema.MaxItems.Value}");
+ if (schema.UniqueItems == true)
+ constraints.Add("unique items");
+
+ if (constraints.Count == 0)
+ return HtmlString.Empty;
+
+ var sb = new System.Text.StringBuilder();
+ _ = sb.Append("@schema.SchemaId
+
+ @dictionaryTypeName
+
This type represents a dictionary mapping string keys to @schema.DisplayName values.
@Model.RenderMarkdown(openApiSchema.Description)
+ @if (openApiSchema.ExternalDocs?.Url != null) + { + var externalDocsUrl = openApiSchema.ExternalDocs.Url.ToString(); + var isElasticDocs = externalDocsUrl.Contains("www.elastic.co/docs") || externalDocsUrl.Contains("elastic.co/guide"); + + @(isElasticDocs ? "Read the reference documentation" : "External documentation") + + } + } + else if (openApiSchema.ExternalDocs?.Url != null) + { + var externalDocsUrl = openApiSchema.ExternalDocs.Url.ToString(); + var isElasticDocs = externalDocsUrl.Contains("www.elastic.co/docs") || externalDocsUrl.Contains("elastic.co/guide"); + + @(isElasticDocs ? "Read the reference documentation" : "External documentation") + + } + + @if (hasEnum) + { +@enumValueThis type can be one of the following:
+ @(await RenderPartialAsync<_UnionOptions, UnionVariantsContext>(CreateUnionContext(openApiSchema.OneOf!, "oneof", rootAncestors))) + } + + @if (hasAnyOf) + { +This type can be any of the following:
+ @(await RenderPartialAsync<_UnionOptions, UnionVariantsContext>(CreateUnionContext(openApiSchema.AnyOf!, "anyof", rootAncestors))) + } + + @* For aggregations, show both aggregation request and aggregate response *@ + @if (hasAggRequest) + { +Properties for configuring the @(schema.DisplayName) aggregation:
Properties returned in the @(schema.DisplayName) aggregate response:
This type allows additional properties of type: @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(CreateSchemaTypeContext(addPropsSchema)))
+ } + + @if (hasExample) + { +@openApiSchema.Example
+ }
+@Model.PropertyName
+ @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(schemaTypeCtx))
+ @if (ctx.IsRequest && Model.IsRequired)
+ {
+ required
+ }
+ else if (!ctx.IsRequest && !Model.IsRequired)
+ {
+ optional
+ }
+ @if (Model.IsRecursive)
+ {
+ @(await RenderPartialAsync<_RecursiveBadge>())
+ }
+ @if (ctx.ShowDeprecated && propSchema.Deprecated == true)
+ {
+ deprecated
+ }
+ @if (ctx.ShowVersionInfo)
+ {
+ var propVersionInfo = propSchema.Extensions?.TryGetValue("x-state", out var propStateValue) == true && propStateValue is System.Text.Json.Nodes.JsonNode propStateNode ? propStateNode.ToString() : null;
+ if (!string.IsNullOrEmpty(propVersionInfo))
+ {
+ @propVersionInfo
+ }
+ }
+
+ @enumVal
+ }
+ @enumVal
+ }
+ @propSchema.Discriminator.PropertyName)
+ }
+ @{var badgeIndex = 0;}
+ @foreach (var unionOpt in badgeOptions)
+ {
+ if (badgeIndex > 0)
+ {
+ or
+ }
+ var isTypeOption = primitiveTypes.Contains(unionOpt) ||
+ primitiveTypes.Contains(unionOpt.TrimEnd('[', ']')) ||
+ char.IsUpper(unionOpt[0]) || unionOpt.EndsWith("[]");
+ @unionOpt
+ badgeIndex++;
+ }
+ @typeInfo.ArrayItemType
+ <string>
+ @(await RenderPartialAsync<_SchemaType, SchemaTypeContext>(dictValueSchemaTypeCtx))
+ @(new HtmlString(result))
diff --git a/src/Elastic.ApiExplorer/Shared/_UnionOptions.cshtml b/src/Elastic.ApiExplorer/Shared/_UnionOptions.cshtml
new file mode 100644
index 000000000..fd19819df
--- /dev/null
+++ b/src/Elastic.ApiExplorer/Shared/_UnionOptions.cshtml
@@ -0,0 +1,203 @@
+@using Elastic.ApiExplorer.Schema
+@using Microsoft.OpenApi
+@inherits RazorSlice@displayVariantName
+