Giter VIP home page Giter VIP logo

openapi-nest-example's Introduction

OpenAPI Generation with NestJS PoC

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:

  1. Create the service spec in xash-v1.yaml and then generate the stubs using yarn run generate-stubs
  2. In the main module required for nestjs initialization, one can directly provider Controllers as imported from @slash-spec/api/api-index. (Check file app.module.ts for an example)
  3. The generated files include a Controller per defined service and a Switch per defined service. Since we cannot use nest annotations on an interface, we are creating a Controller which then calls a Switch with the exact same signature. The Switch is an interface and can hence be provided to the dependency injection container.
  4. Add your own implementation for the various switches that are generated, and then add them in the providers directory for the @Module (check app.module.ts for an example).
  5. For implementations, check files under src/services/*.

Pending items:

  1. Currently the code being generated does not take into account headers, query params, URL params etc. This, however, should be trivial to add.

openapi-nest-example's People

Contributors

rohanprabhu-slash avatar shivambhatia5432 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.