Check the specification file in specification/xash-v1.yaml
Custom mustache templates to follow our conventions are defined under api-generation/templates
Override and configuration of the default nestjs generator is present under api-generation/openapi-generator.yaml
.
To generate the server stubs, run:
yarn run generate-stubs
This will generate server stubs, and models in build/generated
. The overall layout and proposed
workflow is:
- Create the service spec in
xash-v1.yaml
and then generate the stubs usingyarn run generate-stubs
- In the main module required for nestjs initialization, one can directly provider
Controllers
as imported from@slash-spec/api/api-index
. (Check fileapp.module.ts
for an example) - The generated files include a
Controller
per defined service and aSwitch
per defined service. Since we cannot use nest annotations on an interface, we are creating aController
which then calls aSwitch
with the exact same signature. TheSwitch
is an interface and can hence be provided to the dependency injection container. - Add your own implementation for the various switches that are generated, and then add them in the
providers
directory for the@Module
(checkapp.module.ts
for an example). - For implementations, check files under
src/services/*
.
Pending items:
- Currently the code being generated does not take into account headers, query params, URL params etc. This, however, should be trivial to add.