FAQ | This is a LIVE service | Changelog

Skip to content

feat: add the bones of an OpenAPI client generation mechanism

Dr Rich Wareham requested to merge issue-24-schema-generation into main

Add the start of a re-usable OpenAPI client generation mechanism. Add two files: one which represents the repository-local customisation and one which is the re-usable template. Add the start of some documentation for the template with an eye to moving it to the guidebook.

The general idea is that getting OpenAPI clients should be as simple as including an openapi.yaml file in the root of the repository.

Note the name of the file was chosen because GitLab will automatically render files so-named with swagger UI:

image

For our specific use case we want to generate the schema dynamically and so allow for this by means of customising an "openapi:schema" job whose role is to ensure the schema is available to downstream jobs as a CI job artefact. The default behaviour is simply to copy the schema from the repository but we override it to use the DRF spectactular Django management command. We use the --fail-if-warn flag to allow this job to additionally act as a "test" test that schema generation succeeds without warning.

Add in the plumbing to run the openapi-generator CLI but only use it for the moment as an additional "test" job which validates the spec.

The template has been written with an eye to adding to the common pipeline and so that there can be zero configuration required to make use of it. As such the template follows the rules of the common pipeline in being "safe" to include with no side-effects unless it's triggered and all CI variables and artefacts are appropriately namespaced.

Part of #24 (closed). This MR does not include integration with release-it. That is, IMO, better left as a separate MR once the bones are present.

Edited by Dr Rich Wareham

Merge request reports

Loading