OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.23k stars 6.43k forks source link

[BUG] scala-akka issues #2684

Open wing328 opened 5 years ago

wing328 commented 5 years ago

Bug Report Checklist

Description

The scala-akka client has the following issues/limitations:

1. All responses must be documented.

If a response is not documented, an exception will be thrown

The line for this behavior is https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala#L283

2. Enum is not working as expected

Enum (e..g status in Petstore) is converted to {}, e.g.

{"id":1000,"category":{"id":1,"name":"sold"},"name":"dragon","photoUrls":["http://foo.com/photo/1","http://foo.com/photo/2","http://foo.com/photo/3","http://foo.com/photo/4","http://foo.com/photo/5","http://foo.com/photo/6","http://foo.com/photo/7","http://foo.com/photo/8","http://foo.com/photo/9","http://foo.com/photo/10"],"tags":[{"id":1,"name":"tag-1"},{"id":2,"name":"tag-2"},{"id":3,"name":"tag-3"},{"id":4,"name":"tag-4"},{"id":5,"name":"tag-5"}],"status":{}}

Note the "status":{} at the end of the payload

Removing https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/scala-akka/src/test/scala/PetApiTest.scala#L29 from the payload works around the issue for the time being.

3. ContentType is not used in the request

Even content type is set to "application/json" in the request, still "applicatin/octat-stream" is used instead". The line seems to cause the issue is

https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/scala-akka/src/main/scala/org/openapitools/client/core/ApiInvoker.scala#L290

I can workaround the issue by hard coding the following but it's clearly not going to work for all cases.

ContentType(MediaTypes.`application/json`)
openapi-generator version

Latest master

OpenAPI declaration file content or url

petstore.json/yaml

Command line used for generation

./bin/scala-akka-petstore.sh

Steps to reproduce

Run "sbt test" under scala-akka petstore folder.

Suggest a fix

See above

chameleon82 commented 4 years ago

p. 3 was fixed in https://github.com/OpenAPITools/openapi-generator/pull/5106 here i will create separate PR to cover this case with tests