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

Add an Microprofile OpenAPI example #112

Merged
merged 1 commit into from
Feb 16, 2023
Merged

Conversation

liweinan
Copy link
Contributor

No description provided.

@liweinan liweinan marked this pull request as draft February 10, 2023 07:26
@liweinan
Copy link
Contributor Author

liweinan commented Feb 10, 2023

@jamezp I'm working on a SmallRye based OpenAPI example, and I've made some progresses. I plan to make the example based on the current bootable-jar example(I'll move the openapi example into separate submodules later), because it's convenient to boot the WildFly
using the wildfly-jar plugin IMHO.

Here is the jaxrs support provied by the smallrye-open-api project:

Which must be used in an integrated environment such as Quarkus or WildFly. For example, here is the usage of it in Quakrus:

The reason to use it in a container is because the container help to setup the Apis generated by the smallrye framework. For example, in microprofile-open-api test code base, here is a setup to enable it in JDK HttpServer:

68E5B583-281B-4AE5-BF45-3D03A411A203

And here is the handler in Quarkus:

For WildFly, it contains the openapi layer as described in:

image

So I added the layer in the pom.xml of this branch:

                        <layer>microprofile-openapi</layer>

#112 (comment)

However the plugin reports this error:

[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-jar-maven-plugin:8.1.0.Final:package (default) on project products-runner: Provisioning failed: Failed to locate layer [model=standalone name=microprofile-openapi] in the the installation feature-pack layout -> [Help 1]

I'm not sure how to configure this properly. Could you please provide some help on this? Thanks!

@jamezp
Copy link
Contributor

jamezp commented Feb 10, 2023

@liweinan I wonder if we should create a resteasy-microprofile-example. The reason this doesn't work is we're using the wildfly-ee-feature-pack and we'd need to use the full feature pack that includes the microprofile specs. Talking out loud here, I guess maybe it doesn't make sense to make a new set of examples that is separate. Keeping the examples here probably makes the most sense :)

Anyway, you need change the feature pack to org.wildfly:wildfly-galleon-pack.

@liweinan
Copy link
Contributor Author

@jamezp Yes sir! And thanks for the help :D

@liweinan
Copy link
Contributor Author

liweinan commented Feb 10, 2023

The setup works:

image

I need to split this example from bootable-jar-example into smallrye-openapi-example. In addition I need to do some cleanup.

@liweinan liweinan marked this pull request as ready for review February 10, 2023 17:02
@liweinan liweinan self-assigned this Feb 10, 2023
@liweinan liweinan linked an issue Feb 10, 2023 that may be closed by this pull request
@liweinan liweinan requested a review from jamezp February 10, 2023 17:09
@liweinan
Copy link
Contributor Author

liweinan commented Feb 10, 2023

@jamezp I have finished working on the example, could you please help to review it? Thanks!

@liweinan liweinan changed the title Openapi example in progress Add an SmallRye OpenAPI example Feb 10, 2023
Copy link
Contributor

@jamezp jamezp left a comment

Choose a reason for hiding this comment

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

In general we should not name this "smallrye-openapi". SmallRye as an Eclipse MicroProfile OpenAPI implementation. However, here we're using the MicroProfile OpenAPI.

I also question whether or not we should be using the bootable JAR here. If we just use the API's, we could run on WildFly or in other containers. This part doesn't require a change before we can merge this, but it's something we should think about IMO.

@liweinan
Copy link
Contributor Author

@jamezp Thanks for reviewing! I'll modify the PR according to it.

@liweinan
Copy link
Contributor Author

@jamezp I reconfigured the example to use wildfly-plugin instead of wildfly-jar-plugin. After switching the plugin, I can start the wildfly server with:

$ mvn wildfly:run
...
22:21:17,030 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "smallrye-openapi-example.war" (runtime-name: "smallrye-openapi-example.war")
22:21:18,171 INFO  [org.wildfly.extension.microprofile.openapi.smallrye] (MSC service thread 1-8) WFLYMPOAI0004: Registered MicroProfile OpenAPI endpoint '/openapi' for host 'default-host'
22:21:18,392 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 7) RESTEASY002225: Deploying jakarta.ws.rs.core.Application: class dev.resteasy.examples.openapi.ProductApplication
22:21:18,444 INFO  [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 7) HV000001: Hibernate Validator 8.0.0.Final
22:21:18,473 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 7) WFLYUT0021: Registered web context: '/smallrye-openapi-example' for server 'default-server'
22:21:18,507 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "smallrye-openapi-example.war" (runtime-name : "smallrye-openapi-example.war")

And then I can access the service with:

➤ curl http://127.0.0.1:8080/openapi                                                                                                                                                                                                                                                                            22:22:00
---
openapi: 3.0.3
info:
  title: ProductApplication
  version: 1.0.0
servers:
- url: /smallrye-openapi-example
paths:
  /products:
    get:
      responses:
        default:
          description: return a list of products

However, the mvn clean install or mvn integration-test failed with:

image

It seems the project is not deployed:

image

I guess it's the plugin configuration problem, so the testing doesn't deploy the project. However I don't know how to configure it properly, could you please provide some help on this? Thanks!

@liweinan
Copy link
Contributor Author

After reading this doc:

I understand how to configure the plugin for testing. The core part is to add this line:

                            <goal>deploy</goal>

@liweinan
Copy link
Contributor Author

@jamezp I have finished modifying the example. Could you please help to review it again? Thanks! (If it's okay I'll do squash and force push)

Copy link
Contributor

@jamezp jamezp left a comment

Choose a reason for hiding this comment

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

We still need to remove the "smallrye" name as that is an implementation detail. This could just be named "openapi" or "microprofile-openapi", but it shouldn't be named "smallrye-openapi" IMO.

smallrye-openapi/README.adoc Outdated Show resolved Hide resolved
smallrye-openapi/README.adoc Outdated Show resolved Hide resolved
smallrye-openapi/README.adoc Outdated Show resolved Hide resolved
smallrye-openapi/pom.xml Outdated Show resolved Hide resolved
@liweinan liweinan force-pushed the openapi branch 2 times, most recently from a046fbb to df3719e Compare February 16, 2023 18:21
@liweinan liweinan changed the title Add an SmallRye OpenAPI example Add an Microprofile OpenAPI example Feb 16, 2023
@liweinan
Copy link
Contributor Author

@jamezp Thanks for review! I have finished modifications and squash the commits.

@jamezp jamezp merged commit ff66ca1 into resteasy:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an MicroProfile OpenAPI example
2 participants