cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Generated services return void for all operations #57

Closed hoegertn closed 4 years ago

hoegertn commented 4 years ago

I am generating an API client for the following OpenAPI spec: `https://api.ebbrsodd.de/swagger.yaml``

It works well as it generates all models and services but all the methods return Observable<void> and the type of the result is string instead of the model object.

Any idea what I am missing here?

luisfpg commented 4 years ago

The result type is retrieved from the success response, which has status code 2xx, generally 200. You only use default responses, which is normally handled to catch-any-error.

hoegertn commented 4 years ago

Thanks for the info. What do you think about using the default response during generation if it is the only one in the spec?

luisfpg commented 4 years ago

According to the spec:

Sometimes, an operation can return multiple errors with different HTTP status codes, but all of them have the same response structure... You can use the default response to describe these errors collectively, not individually...

The default response is really meant for describing errors, not success responses.

hoegertn commented 4 years ago

Ok, I will see if I can adjust my generating code on the backend. Thanks for the pointer.

hoegertn commented 4 years ago

The generating library is only creating default responses. As I read the spec, errors are a sample of a default response but not the only use case. So I still think that if there is only a default response it should be used to generate the code.

luisfpg commented 4 years ago

Which library are you using?

luisfpg commented 4 years ago

I can't even use Swagger generator because the specification is said to be invalid:

curl -X POST "https://generator.swagger.io/api/gen/clients/typescript-angular" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"swaggerUrl\": \"https://api.ebbrsodd.de/swagger.yaml\"}"
HighSoftWare96 commented 4 years ago

@luisfpg I'm getting a similar issue: I've a lot of responses with 2** that uses $refs and in the SDK generated they are all returning void...

luisfpg commented 4 years ago

@HighSoftWare96 Can you provide the OpenAPI descriptor?