A convenience package for the node/npm environment that wraps the Java library swagger-codegen-cli-2.4.4.jar.
The following dependencies would need to be installed on your machine before running the Swagger Codegen.
- Java, version 7 or higher
- The Java execution path must be on your environment variable
PATH
- npm install -g swagger-nodegen-cli
Same as swagger-codegen-cli.jar without java -jar ...
The main command is swagger-codegen-cli or swagger-nodegen-cli
usage: swagger-codegen-cli <command> [<args>]
usage: swagger-nodegen-cli <command> [<args>]
swagger-codegen-cli help
swagger-nodegen-cli
- Generates an Angular service per defined swagger resource
- Generates models with custom property name flavours: camelCase, PascalCase, snake_case ... (see
swagger-nodegen-cli config-help -l typescript-angular
) - Base path injection with InjectionToken
swagger-nodegen-cli generate -i swagger.yaml -l typescript-angular -o src/services
|-- angular-application
|-- src
| |-- app
| | |-- app.component.html
| | |-- app.component.ts
| | |-- app.component.css
| | |-- app.module.ts
| `-- services
| |-- ...
./src/app/app.module.ts
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ApiModule, BASE_PATH } from '../services';
@NgModule({
imports: [
BrowserModule,
HttpClientModule,
ApiModule
],
declarations: [
AppComponent
],
providers: [
{ provide: BASE_PATH, useValue: 'http://localhost:10010' }
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
swagger-nodegen-cli generate -i swagger.yaml -l nodejs-server -o my-service