-
Notifications
You must be signed in to change notification settings - Fork 6k
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-Angular2] Swagger Codegen Get Methods not Including Parameters #6723
Comments
@gabrielfuller can you post the relevant parts of your swagger.json? |
3.0.0 is still being worked on to support OAS (OpenAPI spec) 3.0 I would suggest you to use the 2.3.0 SNAPSHOT version for the time being. |
While this is still open, I also want to mention that You can reproduce by generating typescript-angular from this spec. In the contacts.service.ts file, there is a function |
@macjohnny So, just got around to testing that particular branch. It technically fixes the bug, allowing the error to go away. That said, it does so by simply not passing the body data at all, even if there is some. For example, the same delete function as before has this signature: public deleteCharactersCharacterIdContacts(characterId: number, contactIds: Array<number>, datasource?: string, token?: string, userAgent?: string, xUserAgent?: string): Observable<{}> {} The Since this bug is a side affect of that branch, I assume it's not best to open a general issue for it. Should I comment and explain the situation in the PR thread? |
@defmonk0 please state your issue in the PR #6754
so how is your parameter supposed to be transmitted? if your request does have query params, they should be added correctly: swagger-codegen/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache Lines 266 to 276 in dc88ed9
|
This is the API I've been using, if you wanna take a look. Inside contacts->delete, it takes a list of contact IDs in the body of the call. I was aware of HttpClient not supporting body data on their delete calls, so I'm unsure how we'd best go about doing it. Technically, if you we use the request method instead of delete, we can do a delete while we pass body data. I'll post over in the PR, so we can get more eyes on it. |
I used the latest 2.3.0 SNAPSHOT and it fixed my issue. |
I'm using 2.3.0 SNAPSHOT and have the same issue, that the "parameter" are not generated at all. |
Something I discovered is that I realized I needed to do was make sure that
the Routes in my API (in my case, C# Web Api) had the correct parameters
defined in the route. Once I added the parameters into the route string
like below, they started appearing when I generate the API.
I went from this:
[HttpGet("GetUser")]
public object GetUser(string userId)
to this:
[HttpGet("GetUser/{userId}")]
public object GetUser(string userId)
That fixed that issue for me.
|
Description
I am using Codegen Java file to create the Typescript-Angular 2 API for my C# web api. The code gen tool creates the correct code for post and put, but get and delete do not include the parameters correctly.
Here is the generated put method:
Here is the read method:
As you can see, in the read method, the command parameter is never added to the HttpClient Get method so my call to the API always fails. Any ideas how to fix it? Am I doing something wrong?
Swagger-codegen version
3.0.0-20171009.075709-6
Command line used for generation
java -jar C:\SimOpSolutions\SOSBrowserClientApp\files\swagger-codegen-cli-3.0.0-20171009.075709-6.jar generate -i http://localhost:5000/swagger/v1/swagger.json -l typescript-angular -o C:\SimOpSolutions\SOSBrowserClientApp\sos-app\src\app\sos-api
pause
The text was updated successfully, but these errors were encountered: