OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.16k stars 599 forks source link

BETA BLOG - MicroProfile OpenAPI endpoint path configuration #26222

Open Azquelt opened 1 year ago

Azquelt commented 1 year ago

The information you provide here will be included in the Open Liberty beta blog post (example), which will be published on openliberty.io/blog/, and potentially elsewhere, to promote this beta feature/function of Open Liberty. For this post to be included in the beta issue please make sure that this is completed by the end of Friday following the GM (Tuesday). The beta and release blogs are created using automation and rely on you following the template's structure. DO NOT REMOVE/ALTER THE <GHA> TAGS THROUGHOUT THIS TEMPLATE.

Please provide the following information: ​

  1. Which Liberty feature(s) does your update relate to?

    Human-readable name (eg WebSockets feature): MicroProfile OpenAPI

    Short feature name (eg websockets-1.0): mpOpenAPI-1.0 up to mpOpenAPI-3.1

  2. Who is the target persona? Who do you expect to use the update? eg application developer, operations.

    Application Deployer

  3. Provide a summary of the update, including the following points:

    • MicroProfile OpenAPI generates and serves OpenAPI documentation for JAX-RS applications deployed to the Open Liberty server. The OpenAPI documentation is served from /openapi and a user interface for browsing this documentation is served from /openapi/ui.

    • With this update, you can configure these paths for these endpoints by adding configuration to your server.xml like this:

      <mpOpenAPI docPath="/myOpenAPI/path" uiPath="/myUi/Path" />
    • This is particularly useful if you want to expose the OpenAPI documentation through a Kubernetes ingress which routes requests to different services based on the path.

    • For example, with this ingress configuration:

      apiVersion: networking.k8s.io/v1
      kind: Ingress
      metadata:
      name: my-ingress
      spec:
      rules:
      - http:
         paths:
         - path: /appA
           pathType: Prefix
           backend:
             service:
               name: appA
               port:
                 number: 9080
    • You could use this server.xml configuration to ensure that the OpenAPI UI is available at /appA/openapi/ui:

      <mpOpenAPI docPath="/appA/openapi" />

      When not set, uiPath defaults to docPath with /ui appended.

What happens next?

Azquelt commented 1 year ago

This is the blog for #25011