
a simple OpenAPI yaml to json converter. May be useful to feed the OpenAPI to an api viewer like Swagger UI.
It is reading the OpenAPI document, bundles it, i.e. it merges all external $ref s into the main document and writes it as JSON to disk.
Getting Started
The openapi-processor-gradle gradle is the easiest way to use the yaml to json processor.
configuring gradle
The gradle plugin will add an openapiProcessor configuration block that is used to configure the openapi processors.
Configuration for a specific processor is going inside it with the processor name (in this case json) as the
configuration block name.
openapiProcessor {
json {
processor 'com.github.hauner.openapi:openapi-processor-json:2021.2'
apiPath = "$projectDir/src/api/openapi.yaml"
targetDir = "$projectDir/build/openapi"
}
}
-
apiPath: (required) the path to theopenapi.yamlfile and the main input for the processor. -
targetDir: (required) the output folder for generating theopenapi.jsonfile.
Samples
See spring mvc sample or spring webflux sample for a complete working spring boot sample with a minimal openapi.yaml.