Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJSONParameters ¶ added in v0.64.1
func ParseJSONParameters(jsonData string) (openapi3.Parameters, error)
ParseJSONParameters parses a JSON string representing OpenAPI parameters.
func ParseJSONSchema ¶ added in v0.64.1
func ParseJSONSchema(namePrefix, jsonSchema string) (*openapi3.Schema, map[string]*openapi3.SchemaRef, error)
ParseJSONSchema parses a JSON schema into an OpenAPI schema.
Notably, it also extracts the `$defs` from the JSON schema and rewrites its `$ref` paths. This is necessary because OpenAPI 3.0 and JSON schema differ in how they handle definitions. Where JSON schema uses `$defs` inside the schema, OpenAPI uses a global `components.schemas` section that is shared by all schemas in the document. We therefore need to extract the `$defs` into independent OpenAPI schemas, and then rewrite the `$ref` paths in the JSON schema to reference `#/components/schemas“ instead of `#/$defs`.
Since the OpenAPI definitions have global scope, we also prefix the definition names with `namePrefix` to avoid collisions.
Types ¶
This section is empty.