@sklandplus/openapi
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@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

  1. Put response body into a JSON -> JSON Schema converter, such as Quicktype.
  2. Copy the generated schema into src/lib/renderer/schema/schemas/${operationName}Response.json.
  3. Make sure the schema has a top-level definition. Quicktype, for example, have the issue where it only outputs definitions without a top-level type and (properties or items) definition. Typically, you should just simply copy the first definition object into the top-level of the schema. If the schema have a top-level type and (properties or items) definition, you are good to go.
  4. 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.
  5. Add the schema to src/lib/renderer/schema/index.ts.
  6. Add the operation to src/lib/renderer/index.ts. Make sure you are using registry.assertThenRef to reference the schema.
  7. After you are done, run yarn dev to start a Swagger UI server locally and check if everything looks good.

Readme

Keywords

Package Sidebar

Install

npm i @sklandplus/openapi

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

1.09 MB

Total Files

9

Last publish

Collaborators

  • waver-velvet
  • sklandplusadmin