sbt-swagger-codegen
sbt-swagger-codegen copied to clipboard
java.lang.Exception: cannot determine Ok result type for addPet
When I run swaggerClientCodeGen
on the YAML from the PetStore example in the online Swagger Editor:
https://editor.swagger.io
I get the following error:
[error] (*:swaggerClientCodeGen) java.lang.Exception: cannot determine Ok result
type for addPet
Is this due to a bug in the plugin or an error in the source document?
From the specification: "it is expected from the documentation to cover a successful operation response and any known errors"
That's why we raise an exception when a successful response is not defined.
I see, but the last paragraph in that spec section says:
"The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call."
So it depends on how to interpret "should". In my understanding "must" means "absolute requirement" and "should" means "not an absolute requirement but please do it anyway". So I don't think the presence of a success code could be depended on. And at least, as seen, the Swagger example doesn't implement it that way.
Btw, here are the standard definitions of "must" and "should": http://www.ietf.org/rfc/rfc2119.txt
Yes, that's true. But we have to generate code from the swagger definition, so we chose to make the successful response definition mandatory, rather than provide a default implementation in case the definition is missing.