sbt-swagger-codegen icon indicating copy to clipboard operation
sbt-swagger-codegen copied to clipboard

java.lang.Exception: cannot determine Ok result type for addPet

Open kavedaa opened this issue 7 years ago • 4 comments

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?

kavedaa avatar Jan 08 '18 21:01 kavedaa

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.

fralken avatar Jan 09 '18 10:01 fralken

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.

kavedaa avatar Jan 09 '18 12:01 kavedaa

Btw, here are the standard definitions of "must" and "should": http://www.ietf.org/rfc/rfc2119.txt

kavedaa avatar Jan 10 '18 14:01 kavedaa

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.

fralken avatar Jan 11 '18 11:01 fralken