swagger-api / swagger-api/swagger-codegen
[python] swagger responses versus API behavior
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
my swagger.json has:
"responses" : {
"200" : {},
"400": {}
}
but the python API ( https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/python/rest.mustache#L176 ) has:
if r.status not in range(200, 206):
raise ApiException(http_resp=r)
which means that when a web service returns a 400, the machinery in the generated client code that converts the JSON response in the body into the swagger-generated response object never happens.
Now maybe the idea is that the caller is supposed to catch ApiException and examine self.status for a 400 error, but then how is the http response body supposed to be converted into the schema specified in the "400" section of the swagger file?
I have also looked at the Java client ( https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java#L525 ) and it also doesn't do the right thing with any http-reponse-code outside of a 2xx
some clarification one how exactly the non-200 responses should be handled would be useful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to modules/swagger-codegen/src/main/resources/python/rest.mustache#L176 and samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java#L525; start by comparing their non-2xx response handling with the declared Swagger responses. Done means the expected treatment of a documented 400 response, including its body and schema conversion, is established and reflected consistently or documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100