Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript] strictNullChecks errors for Configuration.apiKeys #1607

Closed
grktsh opened this issue Dec 4, 2018 · 0 comments · Fixed by #1611
Closed

[typescript] strictNullChecks errors for Configuration.apiKeys #1607

grktsh opened this issue Dec 4, 2018 · 0 comments · Fixed by #1611

Comments

@grktsh
Copy link
Contributor

grktsh commented Dec 4, 2018

Description

When OpenAPI document has security field of apiKey type, openapi-generator generates service classes which have strictNullChecks errors for Configuration.apiKeys.

openapi-generator version

v3.3.3

OpenAPI declaration file content or url
components:
  securitySchemes:
    api_key:
        type: apiKey
        name: X-API-Key
        in: header
security:
- api_key: []
Suggest a fix/enhancement

I'd like to add this.configuration.apiKeys && to the following condition from typescript-angular/api.service.mustache@master

{{#isKeyInHeader}}
        if (this.configuration.apiKeys["{{keyParamName}}"]) {

Here is the definition of Configuration class from typescript-angular/configuration.mustache@master

export class Configuration {
    apiKeys?: {[ key: string ]: string};
    username?: string;
    password?: string;
    accessToken?: string | (() => string);
    basePath?: string;
    withCredentials?: boolean;

    constructor(configurationParameters: ConfigurationParameters = {}) {
        this.apiKeys = configurationParameters.apiKeys;
grktsh added a commit to grktsh/openapi-generator that referenced this issue Dec 4, 2018
wing328 pushed a commit that referenced this issue Dec 6, 2018
* [typescript] Avoid strictNullChecks errors for apiKeys

fix #1607

* Run ./bin/{LANG}-petstore.sh

- ./bin/typescript-angular-petstore-all.sh
- ./bin/typescript-inversify-petstore.sh

* Run ./bin/security/{LANG}-petstore.sh

- ./bin/security/typescript-angular.sh
- ./bin/security/typescript-angular2.sh
- ./bin/security/typescript-inversify.sh

* [typescript] Fix parameter name sanitization

* Fix invalid consumes of petstore-security-test.yaml

* Run ./bin/security/typescript-*.sh
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
…#1611)

* [typescript] Avoid strictNullChecks errors for apiKeys

fix OpenAPITools#1607

* Run ./bin/{LANG}-petstore.sh

- ./bin/typescript-angular-petstore-all.sh
- ./bin/typescript-inversify-petstore.sh

* Run ./bin/security/{LANG}-petstore.sh

- ./bin/security/typescript-angular.sh
- ./bin/security/typescript-angular2.sh
- ./bin/security/typescript-inversify.sh

* [typescript] Fix parameter name sanitization

* Fix invalid consumes of petstore-security-test.yaml

* Run ./bin/security/typescript-*.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant