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-angular] undefined queryParameters when apiKeyQuery exists but no method parameters #7303

Closed
jwoehrle opened this issue Jan 3, 2018 · 0 comments

Comments

@jwoehrle
Copy link

jwoehrle commented Jan 3, 2018

Description

I stumpled upon this issue when trying to generate a client for the Microsoft LUIS API. The complete swagger file can be found at https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/export?DocumentFormat=Swagger&ApiName=LUIS%20Programmatic%20APIs%20v2.0 however see below for a smaller file which illustrates the issue as well.

When generating a typescript-angular client a queryParameters parameter is generated which is not defined if endpoint has no parameters but apiKeyQuery is set within securityDefinitions.

It seems that the {{#hasQueryParams}} in the api.service.mustache file does not respect the apiKeyQuery

Swagger-codegen version

2.3.0

Swagger declaration file content or url
{
  "swagger": "2.0",
  "info": {
    "title": "LUIS Programmatic APIs v2.0",
    "version": "1.0"
  },
  "host": "westus.api.cognitive.microsoft.com",
  "basePath": "/luis/api/v2.0",
  "schemes": [
    "https"
  ],
  "securityDefinitions": {
    "apiKeyHeader": {
      "type": "apiKey",
      "name": "Ocp-Apim-Subscription-Key",
      "in": "header"
    },
    "apiKeyQuery": {
      "type": "apiKey",
      "name": "subscription-key",
      "in": "query"
    }
  },
  "security": [
    {
      "apiKeyHeader": []
    },
    {
      "apiKeyQuery": []
    }
  ],
  "paths" : {
    "/apps/": {
      "get": {}
    }
  }
}
Config file
{
"modelPropertyNaming": "original",
"ngVersion": "5.0.0",
"classPrefix": ""
}
Command line used for generation

java -jar swagger-codegen-cli-2.3.0.jar generate -i "C:\tmp\swagger_example.json" -l typescript-angular -o ./angular_client -DnpmName=LUIS_CLIENT -c config.json

Steps to reproduce

generate the client with above command. See default.service.ts:78 where a variable queryParameters is used which is not defined.

Related issues/PRs
Suggest a fix/enhancement

respect apiKeyQuery for the {{#hasQueryParams}} in api.service.mustache

@jwoehrle jwoehrle changed the title undefined queryParameters when apiKeyQuery but not method parameters undefined queryParameters when apiKeyQuery exists but no method parameters Jan 3, 2018
@jwoehrle jwoehrle changed the title undefined queryParameters when apiKeyQuery exists but no method parameters [typescript-angular] undefined queryParameters when apiKeyQuery exists but no method parameters Jan 4, 2018
AsamK pushed a commit to AsamK/swagger-codegen that referenced this issue Jun 7, 2018
getHasQueryParams only checks if queryParams is not empty, but
query params could also be defined by authMethods.

Fixes swagger-api#7303
bezineb5 added a commit to bezineb5/swagger-codegen that referenced this issue May 19, 2020
bezineb5 added a commit to bezineb5/swagger-codegen that referenced this issue May 19, 2020
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

No branches or pull requests

1 participant