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

[Microprofile] Add option to use tags a client keys and server generator #16673

Merged
merged 41 commits into from
May 7, 2024

Conversation

kiwi-oss
Copy link
Contributor

@kiwi-oss kiwi-oss commented Sep 26, 2023

This adds two features for Microprofile.

One is the configKeyFromClassName option that allows naming the configuration key of the @RegisterRestClient annotation after the annotated API interface.

The effect can be seen in the interfaces under samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/api. Compare to those under e.g. samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/api where a fixed key is used.

The other addition is a server generator which has the feature of properly handling cases where multiple HTTP 2xx responses are defined, see GET /pet/findByTags in modules/openapi-generator/src/test/resources/3_0/petstore-multiple-2xx-responses.yaml.

The various 2xx responses can return different things, e.g. 200 the whole resource, 204 nothing, 206 a partial resource and so on. Therefore, the return type of the related server interface method has to return a generic response type. This can be seen for findPetsByTags in samples/server/petstore/microprofile/src/main/java/org/openapitools/server/api/PetApi.java.

@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg

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
    
    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*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (upcoming 7.1.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.

pravussum and others added 19 commits February 9, 2022 12:08
…erfaces using Mutiny in Java Microprofile library
…roprofile-improvements

# Conflicts:
#	samples/openapi3/client/petstore/spring-stubs-skip-default-interface/src/main/java/org/openapitools/model/ModelApiResponse.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/CatAllOf.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/DogAllOf.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/HasOnlyReadOnly.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/Model200Response.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelApiResponse.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelList.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ModelReturn.java
#	samples/openapi3/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/SpecialModelName.java
#	samples/openapi3/server/petstore/springboot-source/src/main/java/org/openapitools/model/ModelApiResponse.java
#	samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestHeadersApi.java
#	samples/server/petstore/spring-mvc-default-value/src/main/java/org/openapitools/api/TestQueryParamsApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/AnotherFakeApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/FakeClassnameTestApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/PetApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/StoreApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/api/UserApi.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/BigCatAllOf.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/CatAllOf.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/DogAllOf.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/EnumTest.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/FormatTest.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/HasOnlyReadOnly.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/Model200Response.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/ModelList.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/ModelReturn.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/java/org/openapitools/model/SpecialModelName.java
#	samples/server/petstore/spring-mvc-j8-async/src/main/resources/openapi.yaml
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/AnotherFakeApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/FakeClassnameTestApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/PetApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/StoreApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/api/UserApi.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/BigCatAllOf.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/CatAllOf.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/DogAllOf.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/EnumTest.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/FormatTest.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/HasOnlyReadOnly.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/Model200Response.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/ModelList.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/ModelReturn.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/java/org/openapitools/model/SpecialModelName.java
#	samples/server/petstore/spring-mvc-j8-localdatetime/src/main/resources/openapi.yaml
#	samples/server/petstore/spring-mvc-no-nullable/.openapi-generator/VERSION
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/AnotherFakeApi.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/PetApi.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/api/StoreApi.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/BigCatAllOf.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/CatAllOf.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/DogAllOf.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/EnumTest.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/FormatTest.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/HasOnlyReadOnly.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/Model200Response.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/ModelApiResponse.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/ModelReturn.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/java/org/openapitools/model/SpecialModelName.java
#	samples/server/petstore/spring-mvc-no-nullable/src/main/resources/openapi.yaml
#	samples/server/petstore/spring-mvc-spring-pageable/.openapi-generator/VERSION
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/AnotherFakeApi.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/FakeClassnameTestApi.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/PetApi.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/api/UserApi.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/CatAllOf.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/DogAllOf.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/EnumTest.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/FormatTest.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/HasOnlyReadOnly.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/Model200Response.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/ModelApiResponse.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/ModelList.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/ModelReturn.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/java/org/openapitools/model/SpecialModelName.java
#	samples/server/petstore/spring-mvc-spring-pageable/src/main/resources/openapi.yaml
#	samples/server/petstore/spring-mvc/.openapi-generator/VERSION
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/AnotherFakeApi.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeApi.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/FakeClassnameTestApi.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/StoreApi.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/api/UserApi.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/BigCatAllOf.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/CatAllOf.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/DogAllOf.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/EnumTest.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/FormatTest.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/HasOnlyReadOnly.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/Model200Response.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ModelApiResponse.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ModelList.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/ModelReturn.java
#	samples/server/petstore/spring-mvc/src/main/java/org/openapitools/model/SpecialModelName.java
#	samples/server/petstore/spring-mvc/src/main/resources/openapi.yaml
This reverts commit b5bcbde.
Some other generators than those for Micronaut don't seem to be able to
handle this case, so we don't add it to the general pet store document.
@wing328
Copy link
Member

wing328 commented Oct 3, 2023

https://github.com/OpenAPITools/openapi-generator/actions/runs/6312654633/job/17293794844?pr=16673

looks like there're some unresolved merge conflicts

do you minding merging the latest master into your branch and regenerating the samples?

@kiwi-oss
Copy link
Contributor Author

kiwi-oss commented Oct 9, 2023

Done. Sorry for the delay, I was on holidays

@kiwi-oss
Copy link
Contributor Author

@wing328 There is still some failure, but it seems to me that it's not related to my changes because it's in some JavaScript code.
Can you advise how to proceed with this?

@wing328 wing328 removed this from the 7.1.0 milestone Nov 13, 2023
@wing328
Copy link
Member

wing328 commented Apr 24, 2024

@kiwi-oss thanks for the PR. please PM me via Slack when you've to further discuss this.

https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

@oscarobr oscarobr force-pushed the microprofile-server-generator branch from 63d1367 to a58b998 Compare April 24, 2024 09:24
@@ -0,0 +1,8 @@
generatorName: microprofile
Copy link
Member

Choose a reason for hiding this comment

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

can we name the generator as "java-microprofile" instead following the convention of other java server generators?

Copy link
Contributor

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,8 @@
generatorName: microprofile
outputDir: samples/server/petstore/microprofile
Copy link
Member

Choose a reason for hiding this comment

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

please add the new folder to .github/workflows/samples-java-server-jdk8.yaml so that CI will test it moving forward

Copy link
Contributor

Choose a reason for hiding this comment

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

done

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MicroprofileServerCodegen extends JavaClientCodegen {
Copy link
Member

Choose a reason for hiding this comment

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

personally I would suggest NOT to extend a java server with JavaClientCodegen as most options available in JavaClientCodegen won't make sense in the server generator if I understand it correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

The java generator, using the microprofile library, generates an interface that could be used for either client or server.

This is what is being extended. I understand that it seems odd to have a server code generator inherit from a client generator. But we would have to re write the functionality of the java generator.

Do you have a suggestion of how to proceed with this?
Or perhaps it could be listed as a MicroprofileClientCodegen because it could be used for either client of server

Copy link
Member

Choose a reason for hiding this comment

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

right seems odd but to me but it's not a showstopper.

if this way is a good starting point to add the server generator for microprofile, i'm totally ok with that.

@wing328
Copy link
Member

wing328 commented Apr 29, 2024

can you please review the test failure when you've time? https://github.com/OpenAPITools/openapi-generator/actions/runs/8880595750/job/24389070322?pr=16673

@oscarobr
Copy link
Contributor

can you please review the test failure when you've time? https://github.com/OpenAPITools/openapi-generator/actions/runs/8880595750/job/24389070322?pr=16673

This is caused by a mixing of Junit 4 and Junit 5, and unsatisfied dependencies. It seems this was introduced in 7.5.0 and that there have been issues raised for it /issues/18465

@oscarobr
Copy link
Contributor

can you please review the test failure when you've time? https://github.com/OpenAPITools/openapi-generator/actions/runs/8880595750/job/24389070322?pr=16673

This is caused by a mixing of Junit 4 and Junit 5, and unsatisfied dependencies. It seems this was introduced in 7.5.0 and that there have been issues raised for it /issues/18465

The java microprofile library does not build generate correctly, as the microprofile/pom.mustache does not contain the junit 5 dependencies. I noticed that when regenerating the samples it does not modify these existing samples, so the issue has not been uncovered. I have switched the samples generation to junit 4 to resolve my failing build, but there should be a larger fix for the microprofile library

@wing328
Copy link
Member

wing328 commented May 6, 2024

can you please review the test failure in https://github.com/OpenAPITools/openapi-generator/actions/runs/8892195364/job/24617679907?pr=16673 when you've time?

@oscarobr
Copy link
Contributor

oscarobr commented May 6, 2024

can you please review the test failure in https://github.com/OpenAPITools/openapi-generator/actions/runs/8892195364/job/24617679907?pr=16673 when you've time?

done

@wing328
Copy link
Member

wing328 commented May 6, 2024

thanks for the PR. all tests passed. if no one has further feedback, I'll merge it tomorrow.

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)

@wing328 wing328 merged commit dec8a43 into OpenAPITools:master May 7, 2024
116 checks passed
@wing328 wing328 added this to the 7.6.0 milestone May 20, 2024
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.

5 participants