Remove redundant $root_schema

This commit is contained in:
Richard van der Hoff 2024-03-13 17:36:50 +00:00
parent 62393f8760
commit 63638fbbc5
5 changed files with 3 additions and 21 deletions

View file

@ -21,7 +21,7 @@
{{/* note that a `paths` entry can be a $ref */}} {{/* note that a `paths` entry can be a $ref */}}
{{ $params := dict "endpoint" $endpoint "path" $path "root_schema" $api_data }} {{ $params := dict "endpoint" $endpoint "path" $path }}
{{ with $path_data.get }} {{ with $path_data.get }}

View file

@ -6,7 +6,6 @@
* `endpoint`: the endpoint * `endpoint`: the endpoint
* `operation_data`: the OpenAPI data for the operation * `operation_data`: the OpenAPI data for the operation
* `path`: the path where this definition was found, to enable us to resolve "$ref" * `path`: the path where this definition was found, to enable us to resolve "$ref"
* `root_schema`: the root schema object where this definition was found, to enable us to resolve local "$ref" references
This template renders the operation as a `<section>` containing: This template renders the operation as a `<section>` containing:
@ -23,7 +22,6 @@
{{ $endpoint := .endpoint }} {{ $endpoint := .endpoint }}
{{ $operation_data := .operation_data }} {{ $operation_data := .operation_data }}
{{ $path := .path }} {{ $path := .path }}
{{ $root_schema := .root_schema }}
{{ $anchor := anchorize $endpoint }} {{ $anchor := anchorize $endpoint }}
<section class="rendered-data http-api {{ $method }}"> <section class="rendered-data http-api {{ $method }}">
@ -82,7 +80,7 @@
</table> </table>
<hr/> <hr/>
{{ partial "openapi/render-request" (dict "parameters" $operation_data.parameters "request_body" $operation_data.requestBody "path" $path "anchor_base" $anchor "root_schema" $root_schema ) }} {{ partial "openapi/render-request" (dict "parameters" $operation_data.parameters "request_body" $operation_data.requestBody "path" $path "anchor_base" $anchor ) }}
<hr/> <hr/>
{{ partial "openapi/render-responses" (dict "responses" $operation_data.responses "path" $path "anchor_base" $anchor ) }} {{ partial "openapi/render-responses" (dict "responses" $operation_data.responses "path" $path "anchor_base" $anchor ) }}

View file

@ -6,7 +6,6 @@
* `type`: the type of parameters to render: "header", "path", "query" * `type`: the type of parameters to render: "header", "path", "query"
* `caption`: caption to use for the table * `caption`: caption to use for the table
* `path`: the path where this definition was found, to enable us to resolve "$ref" * `path`: the path where this definition was found, to enable us to resolve "$ref"
* `root_schema`: the root schema object where this definition was found, to enable us to resolve local "$ref" references
This template renders a single table containing parameters of the given type. This template renders a single table containing parameters of the given type.
@ -15,7 +14,6 @@
{{ $parameters := .parameters }} {{ $parameters := .parameters }}
{{ $type := .type }} {{ $type := .type }}
{{ $caption := .caption }} {{ $caption := .caption }}
{{ $root_schema := .root_schema }}
{{ $path := .path }} {{ $path := .path }}
{{/* build a dict mapping from name->parameter, which render-object-table expects */}} {{/* build a dict mapping from name->parameter, which render-object-table expects */}}
@ -26,11 +24,7 @@
Per https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object: Per https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object:
the parameters can be reference objects; resolve them now. the parameters can be reference objects; resolve them now.
*/}} */}}
{{ $parameter = partial "openapi/resolve-ref-object" (dict {{ $parameter = partial "openapi/resolve-ref-object" (dict "schema" $parameter "path" $path) }}
"schema" $parameter
"root_schema" $root_schema
"path" $path
) }}
{{ if (eq $parameter.in $type) }} {{ if (eq $parameter.in $type) }}
{{/* {{/*
merge the schema at the same level as the rest of the other fields because that is merge the schema at the same level as the rest of the other fields because that is

View file

@ -5,7 +5,6 @@
* `parameters`: OpenAPI data specifying the parameters * `parameters`: OpenAPI data specifying the parameters
* `request_body`: OpenAPI data specifying the request body * `request_body`: OpenAPI data specifying the request body
* `path`: the path where this definition was found, to enable us to resolve "$ref" * `path`: the path where this definition was found, to enable us to resolve "$ref"
* `root_schema`: the root schema object where this definition was found, to enable us to resolve local "$ref" references
* `anchor_base`: a prefix to add to the HTML anchors generated for each object * `anchor_base`: a prefix to add to the HTML anchors generated for each object
This template renders: This template renders:
@ -18,7 +17,6 @@
{{ $parameters := .parameters }} {{ $parameters := .parameters }}
{{ $request_body := .request_body }} {{ $request_body := .request_body }}
{{ $path := .path }} {{ $path := .path }}
{{ $root_schema := .root_schema }}
{{ $anchor_base := .anchor_base }} {{ $anchor_base := .anchor_base }}
<h2>Request</h2> <h2>Request</h2>
@ -33,22 +31,18 @@
"type" "header" "type" "header"
"caption" "header parameters" "caption" "header parameters"
"path" $path "path" $path
"root_schema" $root_schema
) }} ) }}
{{ partial "openapi/render-parameters" (dict {{ partial "openapi/render-parameters" (dict
"parameters" $parameters "parameters" $parameters
"type" "path" "type" "path"
"caption" "path parameters" "caption" "path parameters"
"path" $path "path" $path
"root_schema" $root_schema
) }} ) }}
{{ partial "openapi/render-parameters" (dict {{ partial "openapi/render-parameters" (dict
"parameters" $parameters "parameters" $parameters
"type" "query" "type" "query"
"caption" "query parameters" "caption" "query parameters"
"root_schema" $root_schema
"path" $path "path" $path
"root_schema" $root_schema
) }} ) }}
{{ end }} {{ end }}

View file

@ -13,16 +13,12 @@ The input parameter is a dict with the following keys:
* `path`: The path of the schema file containing the (potential) ref; used for resolving * `path`: The path of the schema file containing the (potential) ref; used for resolving
relative references. relative references.
* `root_schema`: The top-level schema which contains the potential ref; use for resolving `#/`
references.
Ref: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object. Ref: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object.
*/}} */}}
{{ $schema := .schema }} {{ $schema := .schema }}
{{ $path := .path }} {{ $path := .path }}
{{ $root_schema := .root_schema }}
{{ $ret := $schema }} {{ $ret := $schema }}