Skip to content
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

adding support for @ResponseStatus annotation into spring-http-interface java spring generator #20071

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

alfet81
Copy link

@alfet81 alfet81 commented Nov 9, 2024

Spring-http-interface generator is missing the support for useResponseEntity option for adding @ResponseStatus annotation similar to Java Spring generator. This feature was probably omitted due to the fact that the HTTP interface is mainly used for client side implementations. But there are cases when it also can be used for server side implementations like for example a REST controller which plays a role of a server side implementation thus other micro-services can use the same HTTP interface to make calls to the server-side endpoints utilizing same API. See https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-http-interface.

The change should be made in api.mustache template.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@alfet81
Copy link
Author

alfet81 commented Nov 9, 2024

@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann ) @Zomzog @lwlee2608 @martin-mfg could anybody review and approve. We need this feature ASAP. Thanks.

@alfet81 alfet81 changed the title adding support for useResponseEntity into spring-http-interface java … adding support for useResponseEntity into spring-http-interface java spring generator Nov 9, 2024
@alfet81
Copy link
Author

alfet81 commented Nov 9, 2024

Is it possible to push this change into 7.10 milestone so we can have the feature before the year 2025?

@wing328
Copy link
Member

wing328 commented Nov 10, 2024

thanks for the PR. can we include samples using this option and test it in the CI workflow?

a good starting is to copy bin/configs/spring-http-interface-reactive.yaml

$ cat ./bin/configs/spring-http-interface-reactive.yaml
generatorName: spring
library: spring-http-interface
outputDir: samples/client/petstore/spring-http-interface-reactive
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
  artifactId: spring-http-interface-reactive
  snapshotVersion: "true"
  hideGenerationTimestamp: "true"
  reactive: "true"
  # documentation provider should be ignored
  documentationProvider: "springfox"
  # annotation provider should be ignored
  annotationLibrary: "swagger1"
  # validation should be ignored
  useBeanValidation: "true"
  performBeanValidation: "true"

then add the new sample folder to the workflow: .github/workflows/samples-jdk17.yaml

@alfet81 alfet81 changed the title adding support for useResponseEntity into spring-http-interface java spring generator adding support for @ResponseStatus annotation into spring-http-interface java spring generator Nov 11, 2024
@alfet81
Copy link
Author

alfet81 commented Nov 11, 2024

@wing328 Thanks for your comment. I've pushed couple extra commits per your request. Please let me know if they look fine. Also, should I generate the samples manually and commit them into the repo? I'm not very familiar with Github workflows and how they are used for testing the openapi-generator. So I need some more guidance on that.

@wing328
Copy link
Member

wing328 commented Nov 11, 2024

can you please commit the samples as well so that the CI can test these?

@alfet81
Copy link
Author

alfet81 commented Nov 12, 2024

@wing328 The samples were added.

@wing328
Copy link
Member

wing328 commented Nov 13, 2024

https://github.com/OpenAPITools/openapi-generator/actions/runs/11790584074/job/32930532262?pr=20071

can you please update the samples to fix the CI failure?

@@ -26,7 +26,7 @@ paths:
requestBody:
$ref: "#/components/requestBodies/Pet"
responses:
"200":
"201":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to make any changes in this file? If not, could you revert them please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to use correct statuses for POST/PUT success responses. Gonna revert then.

- samples/client/petstore/java/webclient-jakarta
- samples/client/petstore/java/microprofile-rest-client-outer-enum
# servers
- samples/openapi3/server/petstore/springboot-3
- samples/server/petstore/java-camel/
- samples/server/petstore/java-helidon-server/v3/mp/
- samples/server/petstore/java-helidon-server/v3/se
- samples/client/petstore/spring-http-interface-reactive
- samples/client/petstore/spring-http-interface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to remove these tests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are duplicated. Same paths are already present in the #clients section. Probably copy/paste issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants