-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[scala] fix akka-scala-client template compilation warnings #5106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[scala] fix akka-scala-client template compilation warnings #5106
Conversation
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
add COOKIE location authorization key regenerate template
90df525 to
6bfd5b2
Compare
|
Please update the test case (https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java#L362) to resolve the build failure. |
974f08f to
ef3ac57
Compare
| $ref: '#/components/schemas/Pet' | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Pet' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chameleon82 are these a must? In other words, would the change still work without documenting the HTTP 200 response in the spec?
We prefer not to update petstore.yaml to keep it as original as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 Thanks for calling this out. When you say original, what are we keeping it original compared to? This spec isn't the "official" petstore.yaml spec from OpenAPI Specification 3.0 examples.
I'd have some concerns about not including these changes. It would mean that the PUT and POST methods are only documented to ever return a client error. From https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responsesObject:
A container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors.
The default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.
The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call.
Although the line "documentation is expected to cover a successful operation response" doesn't use the specification terminology MUST, MAY or SHOULD, I think our test yaml breaking 'expectations' could be confusing especially since there is no 'default' response documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 @jimschubert I've checked than one https://petstore3.swagger.io/api/v3/openapi.yaml which currently has those specified, openApi specs also have specified successful response here https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml and here https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore-expanded.yaml
However https://petstore.swagger.io/v2/swagger.yaml has not specified even default one.
Seems that case must be clear in OpenApi Specification.
I suppose SHOULD for successful operation means that client has another way to check result. For example, by calling GET /pet/123 after calling POST /pet {id = 123, ... }
For the current case i have added this to validate successful scenarios in the unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that's probably why they've used SHOULD. However, the common way to do that without a returned body is to use links in the header of a successful response. I think your changes to include 2xx type responses makes sense. If we don't include positive responses for these endpoints, I think we should remove the endpoints entirely, because no realistic API returns only client errors for a path.
@wing328 are you cool with keeping these changes? We should probably also review all our go-to specs and make sure they represent real-world designs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agreed with reviewing the spec to ensure it's correct. Let's go with this PR for the time being.
jimschubert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, and only a minor concern about the removal of the UUID mapping (users can always manually apply this import mapping at generation time).
| {{/imports}} | ||
| import {{mainPackage}}.core.ApiModel | ||
| import org.joda.time.DateTime | ||
| import java.util.UUID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a potential breaking change unless this is added to the constructor:
importMapping.put("UUID", "java.util.UUID");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is already there in ScalaAkkaClientCodegen extends AbstractScalaCodegen extends DefaultCodegen base class.
I will add unit test to check there is no breaking changes for the further versions
| $ref: '#/components/schemas/Pet' | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/Pet' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 Thanks for calling this out. When you say original, what are we keeping it original compared to? This spec isn't the "official" petstore.yaml spec from OpenAPI Specification 3.0 examples.
I'd have some concerns about not including these changes. It would mean that the PUT and POST methods are only documented to ever return a client error. From https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responsesObject:
A container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors.
The default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.
The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call.
Although the line "documentation is expected to cover a successful operation response" doesn't use the specification terminology MUST, MAY or SHOULD, I think our test yaml breaking 'expectations' could be confusing especially since there is no 'default' response documented.
|
For some reasons, I can't comment/reply to #5106 (comment). Agreed with revising the "original" as it may not be perfectly accurate. I'll create a separate issue to track it. |
…ools#5106) * fix akka-scala-client template compilation warnings add COOKIE location authorization key regenerate template * fix scala akka-http client model imports * fix OpenAPITools#4004 custom package name in reference.conf * fix scaka-akka codegen test
PR checklist
./bin/(or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.@clasnake (2017/07), @jimschubert (2017/09) ❤️, @shijinkui (2018/01), @ramzimaalej (2018/03)