@sklandplus/openapi
This package is used to generate the OpenAPI 3.1 schema for the API. Users who wish to use the API directly should refer
to the @sklandplus/client
package instead.
Usage
import { schema } from '@sklandplus/openapi'
console.log(schema)
Contributing
How to add a new API operation
- Put response body into a JSON -> JSON Schema converter, such as Quicktype.
- Copy the generated schema into
src/lib/renderer/schema/schemas/${operationName}Response.json
. - Make sure the schema has a top-level definition. Quicktype, for example, have the issue where it only outputs
definitions
without a top-leveltype
and (properties
oritems
) definition. Typically, you should just simply copy the firstdefinition
object into the top-level of the schema. If the schema have a top-leveltype
and (properties
oritems
) definition, you are good to go. - Make sure the schema does NOT have a top-level
$ref
property. Quicktype, for example, also have this issue and this would cause the Swagger UI to stop rendering the schema. If the schema have a top-level$ref
property, you should remove it. - Add the schema to
src/lib/renderer/schema/index.ts
. - Add the operation to
src/lib/renderer/index.ts
. Make sure you are usingregistry.assertThenRef
to reference the schema. - After you are done, run
yarn dev
to start a Swagger UI server locally and check if everything looks good.