Skip to content

Conversation

laurentvdl
Copy link
Contributor

Changes the generated API classes to use the baseName instead of the parameter name: for a url specified as /resource/{resource_id}, the following incorrect typescript was generated:

var path = this.basePath + '/resource/{resource_id}';

path = path.replace('{' + 'resourceId' + '}', String(resourceId));

which obviously fails to replace the parameter.

Query parameters have a similar problem.

@wing328
Copy link
Contributor

wing328 commented Sep 17, 2015

@laurentvdl thanks for the PR. The change looks good to me. I'll merge it tomorrow (Friday) if no one has further question or feedback on the change.

@wing328
Copy link
Contributor

wing328 commented Sep 17, 2015

@laurentvdl one feedback from me. Shall we update the header parameter to use {{baseName}} instead in this PR?
Change

             headerParams['{{paramName}}'] = {{paramName}};

to

             headerParams['{{baseName}}'] = {{paramName}};

And shall it support form parameters ( {{formParams}} ) as well?

@laurentvdl
Copy link
Contributor Author

Indeed, updated the PR for the headerParams.
As formParams seem to be unsupported in the angular-ts generator, I'll send a separate PR with an implementation.

@wing328
Copy link
Contributor

wing328 commented Sep 18, 2015

@laurentvdl thanks. We'll merge this PR for the time being while you're working on a PR to support formParams.

wing328 added a commit that referenced this pull request Sep 18, 2015
Use the baseName when referring to path and query parameters.
@wing328 wing328 merged commit cf300c0 into swagger-api:master Sep 18, 2015
@wing328
Copy link
Contributor

wing328 commented Sep 20, 2015

@laurentvdl To implement form parameter support in angular-ts generator, I would suggest you to take a look at how node-ts generator implements it: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/TypeScript-node/api.mustache#L191

FYI. I filed #1261 to fix parameter name in node-ts generator based on your fix for angular-ts generator

@laurentvdl laurentvdl deleted the patch branch September 21, 2015 08:50
@laurentvdl
Copy link
Contributor Author

What would be the correct way to check if formParams (any array/list) is empty ?
(I would like to check at generate time, not runtime)

I tried to no avail:

{{#formParams.length}}
            var formsParams: any = {};
{{/formParams.length}}

@wing328
Copy link
Contributor

wing328 commented Sep 21, 2015

formParams.length should work as mentioned in my comment on another PR before: #1076 (comment)

One approach/workaround is to declare the Form parameter hash anyway:https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/ruby/api.mustache#L56

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 this pull request may close these issues.

3 participants