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

java.lang.Exception: Please provide an operationId

Open kavedaa opened this issue 7 years ago • 3 comments

I get the following error when running swaggerClientCodeGen on a (3rd-party generated) yaml file:

[error] (*:swaggerClientCodeGen) java.lang.Exception: Please provide an operationId in ...

As far as I can tell from the specification, operationId is not marked as "Required":

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operationObject

kavedaa avatar Jan 10 '18 13:01 kavedaa

We use the operationId as the method name in the controller, that's why it must be present.

fralken avatar Jan 11 '18 11:01 fralken

Yes, I understand the motivation, but I think that in the context of open standards and interoperability the plugin would be useful to more people if it actually adhered to the specification.

In this case you could for instance fall back to generating a method name from the path, or synthesizing it like operation1, operation2 etc.

That said I would like to add that I still find the plugin very useful, so thanks for creating it and open sourcing it!

kavedaa avatar Jan 11 '18 19:01 kavedaa

Thanks. Indeed we could better respect the specification and provide defaults for non mandatory specifications such as this one (and the successful response of #61). We can implement this in future. In the meantime if you would like to contribute with a PR on this, it would be highly appreciated :)

fralken avatar Jan 12 '18 14:01 fralken