{"_id":"@alexciesielski/ng-openapi-gen","_rev":"2-8b981d143b7764cc71f04086af4cecfd","name":"@alexciesielski/ng-openapi-gen","dist-tags":{"latest":"0.51.3"},"versions":{"0.51.1":{"name":"@alexciesielski/ng-openapi-gen","version":"0.51.1","keywords":["angular","openapi","codegen"],"author":{"name":"Alexander Ciesielski"},"license":"MIT","_id":"@alexciesielski/ng-openapi-gen@0.51.1","maintainers":[{"name":"ciesielskico","email":"alexander@ciesielski.co"}],"homepage":"https://github.com/cyclosproject/ng-openapi-gen#readme","bugs":{"url":"https://github.com/cyclosproject/ng-openapi-gen/issues"},"bin":{"ng-openapi-gen":"lib/index.js"},"dist":{"shasum":"cbe207e84daf8bf75089bdfc85979caedb7d4f75","tarball":"https://registry.npmjs.org/@alexciesielski/ng-openapi-gen/-/ng-openapi-gen-0.51.1.tgz","fileCount":96,"integrity":"sha512-xoqEWRtimHxUU+wATR/FntAQWy+Ai4Dasy68NIxtl7kRk4LIkdl8on+yPjeX0MSpc2HKzaNEiBTmHIVTPoUFVQ==","signatures":[{"sig":"MEUCICFmPNssVfCrzduGg/FU4jRksECXPCE43vI6GBjHcvl8AiEAmUKKbq6pLZRHD0FlI/RIVmYCGGO6OC5RZEVZdm8ck0w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":212033},"main":"lib/ng-openapi-gen.js","types":"./lib/ng-openapi-gen.d.ts","gitHead":"6f159223be07ae44325e553941d2aa31bbf1d164","scripts":{"link":"npm run build && cd dist && npm link","lint":"eslint 'lib/**'","test":"jasmine-ts --project=tsconfig.json --config=jasmine.json","build":"npm run lint && npm run compile && npm test","compile":"tsc --project tsconfig.json && ncp \"LICENSE\" dist && ncp \"README.md\" \"dist/README.md\" && ncp \"templates\" \"dist/templates\" && ncp \"node_modules\" \"dist/node_modules\" && rimraf \"dist/test\"","publish":"npm run build && cd dist && npm publish --access public","test:watch":"nodemon --watch './**/*' --exec 'npm run test'"},"_npmUser":{"name":"ciesielskico","email":"alexander@ciesielski.co"},"repository":{"url":"git+https://github.com/cyclosproject/ng-openapi-gen.git","type":"git"},"_npmVersion":"10.7.0","description":"An OpenAPI 3 codegen for Angular 17+","directories":{},"_nodeVersion":"18.20.3","dependencies":{"eol":"^0.9.1","jsesc":"^3.0.2","lodash":"^4.17.21","argparse":"^2.0.1","fs-extra":"^10.0.1","handlebars":"^4.7.7","typescript":"~5.0.4","json-schema":"^0.4.0","@apidevtools/json-schema-ref-parser":"~9.0.9"},"_hasShrinkwrap":false,"devDependencies":{"mem":"^9.0.2","ncp":"^2.0.0","eslint":"^8.43.0","rimraf":"^5.0.1","jasmine":"^3.10.0","nodemon":"^3.0.1","ts-node":"^10.9.1","jasmine-ts":"^0.4.0","@types/node":"^17.0.23","@types/jsesc":"^3.0.1","@types/lodash":"^4.14.195","@types/mkdirp":"^1.0.2","@types/jasmine":"^3.10.2","@types/argparse":"^2.0.10","@types/fs-extra":"^9.0.13","replace-in-file":"^7.0.1","typescript-parser":"^2.6.1","@types/json-schema":"^7.0.12","eslint-plugin-jsdoc":"^46.4.0","jasmine-spec-reporter":"^7.0.0","@typescript-eslint/parser":"^5.60.1","@loopback/openapi-v3-types":"^1.2.1","@typescript-eslint/eslint-plugin":"^5.60.1","@typescript-eslint/eslint-plugin-tslint":"^5.60.1"},"peerDependencies":{"rxjs":">=7.0.0","@angular/core":">=17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ng-openapi-gen_0.51.1_1725041955883_0.4127965071260118","host":"s3://npm-registry-packages"}},"0.51.2":{"name":"@alexciesielski/ng-openapi-gen","version":"0.51.2","keywords":["angular","openapi","codegen"],"author":{"name":"Alexander Ciesielski"},"license":"MIT","_id":"@alexciesielski/ng-openapi-gen@0.51.2","maintainers":[{"name":"ciesielskico","email":"alexander@ciesielski.co"}],"homepage":"https://github.com/cyclosproject/ng-openapi-gen#readme","bugs":{"url":"https://github.com/cyclosproject/ng-openapi-gen/issues"},"bin":{"ng-openapi-gen":"lib/index.js"},"dist":{"shasum":"8e9aed72f02b28909be4a7fa25d54019ea34fbd1","tarball":"https://registry.npmjs.org/@alexciesielski/ng-openapi-gen/-/ng-openapi-gen-0.51.2.tgz","fileCount":96,"integrity":"sha512-uBw+HEsNF5BHu7BNLd8v3EGnC4NMgPkLo2qHTl3ZyadEuEj08MtQgdZ3x8l8FumExd2v52Hq55oDfX90+FLDAg==","signatures":[{"sig":"MEYCIQCS6sdw4JP1HIkjKbVVRI8YQrDPPxEowtbXUWpc130tFwIhAIbHZGiD3LCA27sHabYiuQLdatXSHpaTf1G1uRJ0y1D5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":212037},"main":"lib/ng-openapi-gen.js","types":"./lib/ng-openapi-gen.d.ts","gitHead":"6f159223be07ae44325e553941d2aa31bbf1d164","scripts":{"link":"npm run build && cd dist && npm link","lint":"eslint 'lib/**'","test":"jasmine-ts --project=tsconfig.json --config=jasmine.json","build":"npm run lint && npm run compile && npm test","compile":"tsc --project tsconfig.json && ncp \"LICENSE\" dist && ncp \"README.md\" \"dist/README.md\" && ncp \"templates\" \"dist/templates\" && ncp \"node_modules\" \"dist/node_modules\" && rimraf \"dist/test\"","test:watch":"nodemon --watch './**/*' --exec 'npm run test'","publish-lib":"npm run build && cd dist && npm publish --access public"},"_npmUser":{"name":"ciesielskico","email":"alexander@ciesielski.co"},"repository":{"url":"git+https://github.com/cyclosproject/ng-openapi-gen.git","type":"git"},"_npmVersion":"10.7.0","description":"An OpenAPI 3 codegen for Angular 17+","directories":{},"_nodeVersion":"18.20.3","dependencies":{"eol":"^0.9.1","jsesc":"^3.0.2","lodash":"^4.17.21","argparse":"^2.0.1","fs-extra":"^10.0.1","handlebars":"^4.7.7","typescript":"~5.0.4","json-schema":"^0.4.0","@apidevtools/json-schema-ref-parser":"~9.0.9"},"_hasShrinkwrap":false,"devDependencies":{"mem":"^9.0.2","ncp":"^2.0.0","eslint":"^8.43.0","rimraf":"^5.0.1","jasmine":"^3.10.0","nodemon":"^3.0.1","ts-node":"^10.9.1","jasmine-ts":"^0.4.0","@types/node":"^17.0.23","@types/jsesc":"^3.0.1","@types/lodash":"^4.14.195","@types/mkdirp":"^1.0.2","@types/jasmine":"^3.10.2","@types/argparse":"^2.0.10","@types/fs-extra":"^9.0.13","replace-in-file":"^7.0.1","typescript-parser":"^2.6.1","@types/json-schema":"^7.0.12","eslint-plugin-jsdoc":"^46.4.0","jasmine-spec-reporter":"^7.0.0","@typescript-eslint/parser":"^5.60.1","@loopback/openapi-v3-types":"^1.2.1","@typescript-eslint/eslint-plugin":"^5.60.1","@typescript-eslint/eslint-plugin-tslint":"^5.60.1"},"peerDependencies":{"rxjs":">=7.0.0","@angular/core":">=17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ng-openapi-gen_0.51.2_1725042008548_0.48206099196596286","host":"s3://npm-registry-packages"}},"0.51.3":{"name":"@alexciesielski/ng-openapi-gen","version":"0.51.3","license":"MIT","author":{"name":"Alexander Ciesielski"},"description":"An OpenAPI 3 codegen for Angular 17+","keywords":["angular","openapi","codegen"],"repository":{"type":"git","url":"git+https://github.com/cyclosproject/ng-openapi-gen.git"},"bin":{"ng-openapi-gen":"lib/index.js"},"main":"lib/ng-openapi-gen.js","scripts":{"test":"jasmine-ts --project=tsconfig.json --config=jasmine.json","lint":"eslint 'lib/**'","compile":"tsc --project tsconfig.json && ncp \"LICENSE\" dist && ncp \"README.md\" \"dist/README.md\" && ncp \"templates\" \"dist/templates\" && ncp \"node_modules\" \"dist/node_modules\" && rimraf \"dist/test\"","build":"npm run lint && npm run compile && npm test","test:watch":"nodemon --watch './**/*' --exec 'npm run test'","link":"npm run build && cd dist && npm link","publish-lib":"npm run build && cd dist && npm publish --access public"},"dependencies":{"@apidevtools/json-schema-ref-parser":"~9.0.9","argparse":"^2.0.1","eol":"^0.9.1","fs-extra":"^10.0.1","handlebars":"^4.7.7","jsesc":"^3.0.2","json-schema":"^0.4.0","lodash":"^4.17.21","typescript":"~5.0.4"},"peerDependencies":{"@angular/core":">=17.0.0","rxjs":">=7.0.0"},"devDependencies":{"@loopback/openapi-v3-types":"^1.2.1","@types/argparse":"^2.0.10","@types/fs-extra":"^9.0.13","@types/jasmine":"^3.10.2","@types/jsesc":"^3.0.1","@types/json-schema":"^7.0.12","@types/lodash":"^4.14.195","@types/mkdirp":"^1.0.2","@types/node":"^17.0.23","@typescript-eslint/eslint-plugin":"^5.60.1","@typescript-eslint/eslint-plugin-tslint":"^5.60.1","@typescript-eslint/parser":"^5.60.1","eslint":"^8.43.0","eslint-plugin-jsdoc":"^46.4.0","jasmine":"^3.10.0","jasmine-spec-reporter":"^7.0.0","jasmine-ts":"^0.4.0","mem":"^9.0.2","ncp":"^2.0.0","nodemon":"^3.0.1","replace-in-file":"^7.0.1","rimraf":"^5.0.1","ts-node":"^10.9.1","typescript-parser":"^2.6.1"},"_id":"@alexciesielski/ng-openapi-gen@0.51.3","gitHead":"b73ec8d4f94722881419d1e1d01aec6573aab9b4","types":"./lib/ng-openapi-gen.d.ts","bugs":{"url":"https://github.com/cyclosproject/ng-openapi-gen/issues"},"homepage":"https://github.com/cyclosproject/ng-openapi-gen#readme","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-Aqx/5ftAqBYqCJqIU9guAOAhEVhZwEsitK0CHGb9DTYKfmtYAb3uwAaKK26bc+OCk/v537CyceJJJPkJMgXkgw==","shasum":"2564ef3c0be69581cc5529bd18445b8f58f3bba4","tarball":"https://registry.npmjs.org/@alexciesielski/ng-openapi-gen/-/ng-openapi-gen-0.51.3.tgz","fileCount":100,"unpackedSize":217145,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCt/aoOFabirPhDG2OmgBgPUM6Ruxyx4lDo85NsrCvjawIhAOsXw4Qj7vHsILhxbBk6kW5RfY3blSuI5ujn71YRz+rB"}]},"_npmUser":{"name":"ciesielskico","email":"alexander@ciesielski.co"},"directories":{},"maintainers":[{"name":"ciesielskico","email":"alexander@ciesielski.co"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ng-openapi-gen_0.51.3_1726062916697_0.43969189803760944"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-30T18:19:15.798Z","modified":"2024-09-11T13:55:17.005Z","0.51.1":"2024-08-30T18:19:16.080Z","0.51.2":"2024-08-30T18:20:08.736Z","0.51.3":"2024-09-11T13:55:16.821Z"},"bugs":{"url":"https://github.com/cyclosproject/ng-openapi-gen/issues"},"author":{"name":"Alexander Ciesielski"},"license":"MIT","homepage":"https://github.com/cyclosproject/ng-openapi-gen#readme","keywords":["angular","openapi","codegen"],"repository":{"type":"git","url":"git+https://github.com/cyclosproject/ng-openapi-gen.git"},"description":"An OpenAPI 3 codegen for Angular 17+","maintainers":[{"name":"ciesielskico","email":"alexander@ciesielski.co"}],"readme":"ng-openapi-gen: An OpenAPI 3 code generator for Angular\n---\n\n![Build status](https://github.com/cyclosproject/ng-openapi-gen/workflows/build/badge.svg)\n![Test status](https://github.com/cyclosproject/ng-openapi-gen/workflows/test/badge.svg)\n\nThis project is a NPM module that generates model interfaces and web service clients from an [OpenApi 3](https://www.openapis.org/) [specification](https://github.com/OAI/OpenAPI-Specification).\nThe generated classes follow the principles of [Angular](https://angular.io/).\nThe generated code is compatible with Angular 12+.\n\nFor a generator for [Swagger 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md), use [ng-swagger-gen](https://github.com/cyclosproject/ng-swagger-gen) instead.\n\n## Highlights\n\n- It should be easy to use and to integrate with Angular CLI;\n- It should support `OpenAPI` specifications in both `JSON` and `YAML` formats;\n- Each tag in the OpenAPI specification generates an Angular `@Injectable()` service;\n- An Angular `@NgModule()` is generated, which provides all services;\n- It should be easy to access the original `HttpResponse`, for example, to read headers.\n  This is achieved by generating a variant suffixed with `$Response` for each generated method;\n- `OpenAPI` supports combinations of request body and response content types.\n  For each combination, a distinct method is generated;\n- It should be possible to specify a subset of services to generate.\n  Only the models actually used by that subset should be generated;\n- It should be easy to specify a root URL for the web service endpoints;\n- Generated files should compile using strict `TypeScript` compiler flags, such as `noUnusedLocals` and `noUnusedParameters`;\n- For large APIs it is possible to generate only functions for each API operation, and not entire services. This allows for tree-shakable code to be generated, resulting in lower bundle sizes.\n\n## Limitations\n\n- 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`. There is, however, support for a few [vendor extensions](#supported-vendor-extensions);\n- Servers per operation are not supported;\n- Only the first server is used as a default root URL in the configuration;\n- No data transformation is ever performed before sending / after returning data.\n  This means that a property of type `string` and format `date-time` will always be generated as `string`, not `Date`.\n  Otherwise every API call would need to have a processing that would traverse the returned object graph before sending the request\n  to replace all date properties by `Date`. The same applies to sent requests. Such operations are out of scope for `ng-openapi-gen`;\n\n## Relationship with ng-swagger-gen\n\nThis project uses the same philosophy as [ng-swagger-gen](https://github.com/cyclosproject/ng-swagger-gen), and was built by the same team.\nWe've learned a lot with `ng-swagger-gen` and have applied all the acquired knowledge to build `ng-openapi-gen`.\n\nThere were several reasons to not build a new major version of `ng-swagger-gen` that supports `OpenAPI 3`, but instead, to create a new project.\nThe main differences between `ng-openapi-gen` and `ng-swagger-gen` are:\n\n- The first, more obvious and more important is the specification version, `OpenAPI 3` vs `Swagger 2`;\n- The generator itself is written in `TypeScript`, which should be easier to maintain;\n- There is an extensive test suite for the generator;\n- The command-line arguments are more robust, derived directly from the `JSON schema` definition for the configuration file, easily allowing to override any specific configuration on CLI.\n- Root enumerations (schemas of `type` = `string` | `number` | `integer`) can be generated as TypeScript's `enum`'s.\nThis is enabled by default. Inline enums are not, because it would require another type to be exported in the container type.\n\n## Installing and running\n\nYou may want to install `ng-openapi-gen` globally or just on your project. Here is an example for a global setup:\n\n```bash\n$ npm install -g ng-openapi-gen\n$ ng-openapi-gen --input my-api.yaml --output my-app/src/app/api\n```\n\nAlternatively you can use the generator directly from within your build-script:\n\n```typescript\nimport $RefParser from 'json-schema-ref-parser';\nimport { NgOpenApiGen } from 'ng-openapi-gen';\n\nconst options = {\n  input: \"my-api.json\",\n  output: \"my-app/src/app/api\",\n}\n\n// load the openapi-spec and resolve all $refs\nconst RefParser = new $RefParser();\nconst openApi = await RefParser.bundle(options.input, {\n  dereference: { circular: false }\n});\n\nconst ngOpenGen = new NgOpenApiGen(openApi, options);\nngOpenGen.generate();\n```\n\nThis will expect the file `my-api.yaml` (or `my-api.json`) to be in the current directory, and will generate the files on `my-app/src/app/api`.\n\n## Configuration file and CLI arguments\n\nIf the file `ng-openapi-gen.json` exists in the current directory, it will be read. Alternatively, you can run `ng-openapi-gen --config my-config.json` (could also be `-c`) to specify a different configuration file, or even specify the input / output as `ng-openapi-gen -i input.yaml` or `ng-openapi-gen -i input.yaml -o /tmp/generation`.\nThe only required configuration property is `input`, which specified the `OpenAPI` specification file. The default `output` is `src/app/api`.\n\nFor a list with all possible configuration options, see the [JSON schema file](https://raw.githubusercontent.com/cyclosproject/ng-openapi-gen/master/ng-openapi-gen-schema.json).\nYou can also run `ng-openapi-gen --help` to see all available options.\nEach option in the JSON schema can be passed in as a CLI argument, both in camel case, like `--includeTags tag1,tag2,tag3`, or in kebab case, like `--exclude-tags tag1,tag2,tag3`.\n\nHere is an example of a configuration file:\n\n```json\n{\n  \"$schema\": \"node_modules/ng-openapi-gen/ng-openapi-gen-schema.json\",\n  \"input\": \"my-file.json\",\n  \"output\": \"out/person-place\",\n  \"ignoreUnusedModels\": false\n}\n```\n\n## Specifying the root URL / web service endpoint\n\nThe easiest way to specify a custom root URL (web service endpoint URL) is to\nuse `forRoot` method of `ApiModule` and set the `rootUrl` property from there.\n\n```typescript\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    HttpClientModule,\n    ApiModule.forRoot({ rootUrl: 'https://www.example.com/api' }),\n  ],\n  bootstrap: [\n    AppComponent\n  ]\n})\nexport class AppModule { }\n```\n\nAlternatively, you can inject the `ApiConfiguration` instance in some service\nor component, such as the `AppComponent` and set the `rootUrl` property there.\n\n## Using functional API calls\n\nStarting with version 0.50.0, `ng-openapi-gen` generates a function with the implementation of each actual API call.\nThe generated services delegate to such functions.\n\nHowever, it is possible to disable the entire services generation, which will avoid the need to include all such services in the application.\nAs a result, the application will be more tree-shakable, resulting in smaller bundle sizes.\nThis is specially true for large 3rd party APIs, in which, for example, a single service (OpenAPI tag) has many methods, but only a few are actually used.\nCombined with the option `\"enumStyle\": \"alias\"`, the footprint of the API generation will be minimal.\n\nEach generated function receives the following arguments:\n\n- Angular's `HttpClient` instance;\n- The API `rootUrl` (the operation knowns the relative URL, and will use this root URL to build the full endpoint path);\n- The actual operation parameters. If it has no parameters or all parameters are optional, the params option will be optional as well;\n- The optional http context.\n\nClients can directly call the function providing the given parameters.\nHowever, to make the process smoother, it is also possible to generate a general service specifically to invoke such functions.\nIts generation is disabled by default, but can be enabled by setting the option `\"apiService\": \"ApiService\"` (or another name your prefer).\nWith this, a single `@Injectable` service is generated. It will provide the functions with the `HttpClient` and `rootUrl` (from `ApiConfiguration`).\n\nIt then provides 2 methods for invoking the functions:\n\n- `invoke`: Calls the function and returns the response body;\n- `invoke$Response`: Calls the function and returns the entire response, so additional metadata can be read, such as status code or headers.\n\nHere is an example class using the `ApiService`:\n\n```typescript\nimport { Directive, OnInit, inject } from '@angular/core';\nimport { ApiService } from 'src/api/api.service';\nimport { getResults } from 'src/api/fn/api/get-results';\nimport { Result } from 'src/api/models';\nimport { Observable } from 'rxjs';\n\n@Directive()\nexport class ApiFnComponent implements OnInit {\n  results$!: Observable<Result[]>;\n\n  apiService = inject(ApiService);\n\n  ngOnInit() {\n    // getResults is the operation function. The second argument is the actual parameters passed to the function\n    this.results$ = this.apiService.invoke(getResults, { limit: 10 });\n  }\n}\n```\n\n## Passing request headers / customizing the request\n\nTo pass request headers, such as authorization or API keys, as well as having a\ncentralized error handling, a standard\n[HttpInterceptor](https://angular.io/guide/http#intercepting-all-requests-or-responses) should\nbe used. It is basically an `@Injectable` that is called before each request,\nand can customize both requests and responses.\n\nHere is an example:\n\n```typescript\n@Injectable()\nexport class ApiInterceptor implements HttpInterceptor {\n  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n    // Apply the headers\n    req = req.clone({\n      setHeaders: {\n        'ApiToken': '1234567890'\n      }\n    });\n\n    // Also handle errors globally\n    return next.handle(req).pipe(\n      tap(x => x, err => {\n        // Handle this err\n        console.error(`Error performing request, status code = ${err.status}`);\n      })\n    );\n  }\n}\n```\n\nThen, both the `HttpInterceptor` implementation and the injection token\n`HTTP_INTERCEPTORS` pointing to it must be provided in your application module,\nlike this:\n\n```typescript\nimport { NgModule, Provider, forwardRef } from '@angular/core';\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\n\nimport { ApiInterceptor } from './api.interceptor';\n\nexport const API_INTERCEPTOR_PROVIDER: Provider = {\n  provide: HTTP_INTERCEPTORS,\n  useExisting: forwardRef(() => ApiInterceptor),\n  multi: true\n};\n\n@NgModule({\n  providers: [\n    ApiInterceptor,\n    API_INTERCEPTOR_PROVIDER\n  ]\n})\nexport class AppModule {}\n```\n\nFiner control over specific requests can also be achieved, such as:\n\n- Set the immediate next request to use a BASIC authentication for login, and\n  the subsequent ones to use a session key in another request header;\n- Set the next request to not use the default error handling, and handle errors\n  directly in the calling code.\n\nTo do so, just create another shared `@Injectable()`, for example, called\n`ApiRequestConfiguration`, which has state for such special cases. Then inject\nit on both the `HttpInterceptor` and in the client code that makes requests.\nHere is an example for such class for controlling the authentication:\n\n```typescript\nimport { Injectable } from '@angular/core';\nimport { HttpRequest } from '@angular/common/http';\n\n/**\n * Configuration for the performed HTTP requests\n */\n@Injectable()\nexport class ApiRequestConfiguration {\n  private nextAuthHeader: string;\n  private nextAuthValue: string;\n\n  /** Set to basic authentication */\n  basic(user: string, password: string): void {\n    this.nextAuthHeader = 'Authorization';\n    this.nextAuthValue = 'Basic ' + btoa(user + ':' + password);\n  }\n\n  /** Set to session key */\n  session(sessionKey: string): void {\n    this.nextAuthHeader = 'Session';\n    this.nextAuthValue = sessionKey;\n  }\n\n  /** Clear any authentication headers (to be called after logout) */\n  clear(): void {\n    this.nextAuthHeader = null;\n    this.nextAuthValue = null;\n  }\n\n  /** Apply the current authorization headers to the given request */\n  apply(req: HttpRequest<any>): HttpRequest<any> {\n    const headers = {};\n    if (this.nextAuthHeader) {\n      headers[this.nextAuthHeader] = this.nextAuthValue;\n    }\n    // Apply the headers to the request\n    return req.clone({\n      setHeaders: headers\n    });\n  }\n}\n```\n\nThen change the `ApiInterceptor` class to call the `apply` method.\nAnd, of course, add `ApiRequestConfiguration` to your module `providers` and\ninject it on your components or services.\n\n## Setting up a node script\n\nRegardless If your Angular project was generated or is managed by\n[Angular CLI](https://cli.angular.io/), or you have started your project with\nsome other seed (for example, using [webpack](https://webpack.js.org/)\ndirectly), you can setup a script to make sure the generated API classes are\nconsistent with the swagger descriptor.\n\nTo do so, create the `ng-openapi-gen.json` configuration file and add the\nfollowing `scripts` to your `package.json`:\n```json\n{\n  \"scripts\": {\n    \"ng-openapi-gen\": \"ng-openapi-gen\",\n    \"start\": \"npm run ng-openapi-gen && npm run ng -- serve\",\n    \"build\": \"npm run ng-openapi-gen && npm run ng -- build -prod\"\n  }\n}\n```\nThis way whenever you run `npm start` or `npm run build`, the API classes\nwill be generated before actually serving / building your application.\n\nAlso, if you use several configuration files, you can specify multiple times\nthe call to `ng-openapi-gen`, like:\n```json\n{\n  \"scripts\": {\n    \"ng-openapi-gen\": \"ng-openapi-gen\",\n    \"generate.api1\": \"npm run ng-openapi-gen -c api1.json\",\n    \"generate.api2\": \"npm run ng-openapi-gen -c api2.json\",\n    \"generate\": \"npm run generate.api1 && npm run generate.api2\",\n    \"start\": \"npm run generate && npm run ng -- serve\",\n    \"build\": \"npm run generate && npm run ng -- build -prod\"\n  }\n}\n```\n\n## Supported vendor extensions\n\nBesides the OpenAPI 3 specification, the following vendor extensions are supported:\n\n- `x-operation-name`: Defined in [LoopBack](https://loopback.io/doc/en/lb4/Decorators_openapi.html), this extension can be used in operations to specify the actual method name. The `operationId` is required to be unique among all tags, but with this extension, a shorter method name can be used per tag (service). Example:\n\n```yaml\npaths:\n  /users:\n    get:\n      tags:\n        - Users\n      operationId: listUsers\n      x-operation-name: list\n      # ... \n  /places:\n    get:\n      tags:\n        - Places\n      operationId: listPlaces\n      x-operation-name: list\n      # ...\n```\n\n- `x-enumNames`: Generated by [NSwag](https://github.com/RicoSuter/NSwag), this extension allows schemas which are enumerations to customize the enum names. It must be an array with the same length as the actual enum values. Example:\n\n```yaml\ncomponents:\n  schemas:\n    HttpStatusCode:\n      type: integer\n      enum:\n        - 200\n        - 404\n        - 500\n      x-enumNames:\n        - OK\n        - NOT_FOUND\n        - INTERNAL_SERVER_ERROR\n```\n\n## Customizing templates\n\nYou can customize the Handlebars templates by copying the desired files from the [templates](https://github.com/cyclosproject/ng-openapi-gen/tree/master/templates) folder (only the ones you need to customize) to some folder in your project, and then reference it in the configuration file.\n\nFor example, to make objects extend a base interface, copy the \n[object.handlebars](https://github.com/cyclosproject/ng-openapi-gen/tree/master/templates) file to your `src/templates` folder. \nThen, in `ng-openapi-gen.json` file, set the following: `\"templates\": \"src/templates\"`.\nFinally, the customized `src/templates/object.handlebars` would look like the following (based on the 0.17.2 version, subject to change in the future):\n\n```handlebars\n{{^hasSuperClasses}}import { BaseModel } from\n'app/base-model';{{/hasSuperClasses}}\n\nexport interface {{typeName}}\n{{#hasSuperClasses}} extends {{#superClasses}}{{{.}}}{{^@last}},\n{{/@last}}{{/superClasses}}{{/hasSuperClasses}}\n{{^hasSuperClasses}} extends BaseModel{{/hasSuperClasses}}\n{\n{{#properties}}\n{{{tsComments}}}{{{identifier}}}{{^required}}?{{/required}}: {{{type}}};\n{{/properties}}\n{{#additionalPropertiesType}}\n\n[key: string]: {{{.}}};\n{{/additionalPropertiesType}}\n}\n```\n\n## Custom Handlebars helpers\n\nYou can integrate your own Handlebar helpers for custom templates. To do so simply provide a `handlebars.js` file in the same directory as your templates that exports a function that recieves the Handlebars instance that will be used when generating the code from your templates.\n\n```js\nmodule.exports = function(handlebars) {\n  // Adding a custom handlebars helper: loud\n  handlebars.registerHelper('loud', function (aString) {\n    return aString.toUpperCase()\n  });\n};\n```\n\n## Developing and contributing\n\nThe generator itself is written in TypeScript. When building, the code is transpiled to JavaScript in the `dist` folder. And the `dist` folder is the one that gets published to NPM. Even to prevent publishing from the wrong path, the `package.json` file has `\"private\": true`, which gets replaced by `false` in the build process.\n\nOn the other hand, for developing / running tests, `jasmine-ts` is used, so the tests run directly from TypeScript. There's even a committed VisualStudio Code debug configuration for tests.\n\nAfter developing the changes, to `link` the module and test it with other node projects, run the following:\n\n```bash\nnpm run build\ncd dist\nnpm link\n```\n\nAt that point, the globally available ng-openapi-gen will be the one compiled to the `dist` folder.\n","readmeFilename":"README.md"}