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

SDK generation not handling URL path variables #498

Closed
zjost opened this issue Aug 28, 2017 · 2 comments
Closed

SDK generation not handling URL path variables #498

zjost opened this issue Aug 28, 2017 · 2 comments
Assignees
Labels

Comments

@zjost
Copy link

zjost commented Aug 28, 2017

When trying to recreate the example in the docs, the generated javascript GET methods like apigClient.helloNameGet({name: 'jimmy'}) that are supposed to use parameters to construct the path don't seem to work. When using chrome inspect it looks like it's not adding "jimmy" to the URL.

When constructing an example like @app.route('/{name}/hello') then the javascript makes an api call to <BASE>/api//hello.

@zjost
Copy link
Author

zjost commented Aug 28, 2017

Note: If I modify apigClient.js to add the variable name into the key list for object parsing, it seems to work. For instance, in apigClient.helloNameGet, I have to modify var helloNameGetRequest value for the path key to go from:

path: pathComponent + uritemplate('/hello/{name}').expand(apiGateway.core.utils.parseParametersToObject(params, [])),

to:

path: pathComponent + uritemplate('/hello/{name}').expand(apiGateway.core.utils.parseParametersToObject(params, ['name'])),

@jamesls
Copy link
Member

jamesls commented Aug 29, 2017

Thanks, this is a confirmed bug. I believe this regressed when we switched over to generating a swagger file internally. I think the parameters field we generate isn't at the right level of nesting. It also appears that API Gateway ignores fields it doesn't understand:

What we generate

          "paths": {
            "/hello/{name}": {
              "get": {
                "responses": {
                  "200": {
                    "description": "200 response",
                    "schema": {
                      "$ref": "#/definitions/Empty"
                    }
                  }
                },
                "x-amazon-apigateway-integration": {
                  "contentHandling": "CONVERT_TO_TEXT",
                  "responses": {
                    "default": {
                      "statusCode": "200"
                    }
                  },
                  "parameters": [
                    {
                      "required": true,
                      "type": "string",
                      "name": "name",
                      "in": "path"
                    }
                  ],

What we actually need to generate

    "/hello/{name}": {
      "get": {
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "200 response",
            "schema": {
              "$ref": "#/definitions/Empty"
            }
          }
        },
        "x-amazon-apigateway-integration": {
          "responses": {
            "default": {
              "statusCode": "200"
            }
          },

Note the parameters should be moved up a level.

Thanks for reporting we'll get this fixed.

@jamesls jamesls added the bug label Aug 29, 2017
@jamesls jamesls self-assigned this Aug 30, 2017
jamesls added a commit to jamesls/chalice that referenced this issue Aug 30, 2017
This should not be in the x-amazon-apigateway-integration
key but instead in the key for the http method which is up
one level.

Fixes aws#498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants