Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions layouts/partials/openapi/endpoint.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ <h4>Request Body</h4>
{{ end }}
{{ end }}

{{/* Request/response examples hidden for now — revisit once example
quality is validated across the full public spec. */}}
{{/* {{ template "openapi/request-example.html" (dict "method" .method "path" .path "details" .details) }} */}}
{{ template "openapi/request-example.html" (dict "method" .method "path" .path "details" .details) }}

<h4>Responses</h4>
{{/* Split responses: inline-rendered (all 2xx + any 4xx/5xx with a JSON schema) vs. stock errors (4xx/5xx with no schema, rendered as compact chip row). */}}
Expand Down Expand Up @@ -129,7 +127,7 @@ <h4>Responses</h4>
{{ if isset $responseDetails.content "application/json" }}
{{ $schema := index $responseDetails.content "application/json" "schema" }}
{{ template "openapi/response-schema.html" (dict "schema" $schema "openapi" $.openapi) }}
{{/* {{ template "openapi/examples.html" (dict "responseDetails" $responseDetails "responseCode" $responseCode "openapi" $.openapi) }} */}}
{{ template "openapi/examples.html" (dict "responseDetails" $responseDetails "responseCode" $responseCode) }}
{{ end }}
{{ end }}
</div>
Expand Down
26 changes: 15 additions & 11 deletions layouts/partials/openapi/request-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ <h4>Example Request</h4>
{{- $url = printf "%s?%s" $url (delimit $queryParts "&") }}
{{- end }}

{{/* Build the curl command line by line. */}}
{{/* Read the request body example from the native OpenAPI 3 mediaType.example slot. */}}
{{- $bodyData := "" }}
{{- with .details.requestBody }}
{{- with index .content "application/json" }}
{{- if .example }}
{{- $bodyData = .example | jsonify (dict "indent" " ") }}
{{- end }}
{{- end }}
{{- end }}

{{- $lines := slice "curl \\" }}
{{- $lines = $lines | append " -H \"Accept: application/vnd.pulumi+8\" \\" }}
{{- $lines = $lines | append " -H \"Content-Type: application/json\" \\" }}
{{- if $bodyData }}
{{- $lines = $lines | append " -H \"Content-Type: application/json\" \\" }}
{{- end }}
{{- $lines = $lines | append " -H \"Authorization: token $PULUMI_ACCESS_TOKEN\" \\" }}
{{- if ne $method "GET" }}
{{- $lines = $lines | append (printf " --request %s \\" $method) }}
{{- end }}
{{- with .details.requestBody }}
{{- $jsonContent := index .content "application/json" }}
{{- with $jsonContent }}
{{- $bodyData := "{}" }}
{{- if .example }}
{{- $bodyData = .example | jsonify }}
{{- end }}
{{- $lines = $lines | append (printf " --data '%s' \\" $bodyData) }}
{{- end }}
{{- if $bodyData }}
{{- $lines = $lines | append (printf " --data '%s' \\" $bodyData) }}
{{- end }}
{{- $lines = $lines | append (printf " %s" $url) }}
<pre><code>{{ delimit $lines "\n" }}</code></pre>
Expand Down
Loading