The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

DESCRIPTION

OpenAPI::Render is a class meant to be subclassed and used to render OpenAPI specifications. Currently OpenAPI version 3.0.2 is the target version, but in principle all 3.* versions should work. OpenAPI::Render provides methods for representing OpenAPI definitions such as operations and parameters, and the base class performs the required traversal. Thus it should be enough to subclass it and override the appropriate methods. For examples see OpenAPI::Render::HTMLForms and OpenAPI::Render::reStructuredText.

MAIN METHODS

new( $openapi )

Given an OpenAPI specification in raw JSON or parsed data structure, constructs a OpenAPI::Render object. Does not modify input values.

show()

Main generating method (does not take any parameters). Returns a string with rendered representation of an OpenAPI specification.

RENDERING METHODS

header()

Text added before everything else. Empty in the base class.

footer()

Text added after everything else. Empty in the base class.

path_header( $path )

Text added before each path. Empty in the base class.

operation_header( $path, $operation )

Text added before each operation. Empty in the base class.

parameters_header()

Text added before parameters list. Empty in the base class.

parameter( $parameter )

Returns representation of a single parameter. Empty in the base class.

parameters_footer()

Text added after parameters list. Empty in the base class.

responses_header()

Text added before responses list. Empty in the base class.

response( $response )

Returns representation of a single response. Empty in the base class.

responses_footer()

Text added after responses list. Empty in the base class.

operation_footer( $path, $operation )

Text added after each operation. Empty in the base class.

HELPER METHODS

api()

Returns the parsed and dereferenced input OpenAPI specification. Note that in the returned data structure all references are dereferenced, i.e., flat.

parameters( $path, $operation )

Returns the list of parameters. Optionally, path and operation can be given to filter the parameters. Note that object-typed schemas from multipart/form-data are translated to parameters too.