Add HTML ids for object definitions in the formatted specification (#1174)
* Remove redundant call to resolve-allof All of the callers to resolve-additional-types already call resolve-allof (or if not, they should), so this is redundant. * Update `resolve-additional-types` to take a dict I want to add more params to this, so first make it take a dict. * `render-object-table`: take a "title" rather than a "caption" ... which means we can use the result from resolve-additional-types directly. * render-object-table: support adding an anchor to generated tables. * resolve-additional-types: generate an id for each returned type * render-event: pass an anchor_base into resolve-additional-types This means that it will generate an anchor for each type, whihc will then be passed into render-object-table and used as an `id` for the table. * render-operation: pass an anchor_base into resolve-additional-types * newsfiles
This commit is contained in:
parent
16eb4cb961
commit
5f3b34448d
14 changed files with 64 additions and 36 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
* `parameters`: OpenAPI/Swagger data specifying the parameters
|
||||
* `path`: the path where this definition was found, to enable us to resolve "$ref"
|
||||
* `anchor_base`: a prefix to add to the HTML anchors generated for each object
|
||||
|
||||
This template renders:
|
||||
* the "simple parameters" (header, path, query parameters)
|
||||
|
@ -14,6 +15,7 @@
|
|||
|
||||
{{ $parameters := .parameters }}
|
||||
{{ $path := .path }}
|
||||
{{ $anchor_base := .anchor_base }}
|
||||
|
||||
<h2>Request</h2>
|
||||
|
||||
|
@ -38,10 +40,10 @@
|
|||
{{ $schema := partial "json-schema/resolve-refs" (dict "schema" $body_parameter.schema "path" $path) }}
|
||||
{{ $schema := partial "json-schema/resolve-allof" $schema }}
|
||||
|
||||
{{ $additional_types := partial "json-schema/resolve-additional-types" $schema }}
|
||||
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base) }}
|
||||
{{ $additional_types = uniq $additional_types }}
|
||||
{{ range $additional_types }}
|
||||
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
|
||||
{{ partial "openapi/render-object-table" . }}
|
||||
{{ end }}
|
||||
|
||||
<h3>Request body example</h3>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue