Skip to content

Conversation

@alfet81
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor 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
Contributor Author

alfet81 commented Nov 12, 2024

@wing328 The samples were added.

@wing328
Copy link
Member

wing328 commented Nov 13, 2024

$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
Contributor 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/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
Contributor 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.

@wing328 wing328 merged commit b44ba66 into OpenAPITools:master Nov 16, 2024
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment