Skip to content

eJuke/ng-openapi-gen

 
 

Repository files navigation

ng-openapi-gen: An OpenAPI 3 code generator for Angular

This project is a NPM module that generates model interfaces and web service clients from an OpenApi 3 specification. The generated classes follow the principles of Angular. The generated code is compatible with Angular 6+.

For a generator for Swagger 2.0, use ng-swagger-gen instead.

ng-openapi-gen is still in early development stage, and is not yet recommended for production.

Highlights

  • It should be easy to use and to integrate with Angular CLI;
  • It should support OpenAPI specifications in both JSON and YAML formats;
  • Each tag in the OpenAPI specification generates an Angular @Injectable() service;
  • An Angular @NgModule() is generated, which provides all services;
  • It should be easy to access the original HttpResponse, for example, to read headers. This is achieved by generating a variant suffixed with $Response for each generated method;
  • OpenAPI supports combinations of request body and response content types. For each combination, a distinct method is generated;
  • It should be possible to specify a subset of services to generate. Only the models actually used by that subset should be generated;
  • It should be easy to specify a root URL for the web service endpoints;
  • Generated files should compile using strict TypeScript compiler flags, such as noUnusedLocals and noUnusedParameters.

Limitations

  • Only standard OpenAPI 3 descriptions will be generated. ng-swagger-gen allows several extensions, specially types from JSON schema, but they are out of scope for ng-openapi-gen;
  • Servers per operation are not supported;
  • Only the first server is used as a default root URL in the configuration;
  • No data transformation is ever performed before sending / after returning data. This means that