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

[3.x] Various metrics test improvements to avoid intermittent failures #5613

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b6e904c
Add OpenAPI U/I integration
tjquinno Nov 7, 2022
52f056f
Fix bad test
tjquinno Nov 7, 2022
fdefc40
OpenAPU U/I - changes in openapi
tjquinno Nov 19, 2022
1b8969f
Allow OpenAPISupport.Builder to accept a UI builder; fix text handlin…
tjquinno Nov 20, 2022
d7435b4
Make OpenApiUi.Builder provide OpenApiUi; update related .adoc files
tjquinno Nov 20, 2022
eed6298
generated adoc for OpenApiUi
tjquinno Nov 20, 2022
e9abdf3
Remove unneeded .adoc from builder
tjquinno Nov 20, 2022
4aa9327
Added test; minor addition to the doc for the U/I support - more to c…
tjquinno Nov 20, 2022
2144550
Generatlize builders and types a bit; change full impl to match chang…
tjquinno Nov 21, 2022
46c3413
Updates to doc (still in progress); add support for U/I to MP OpenAPI
tjquinno Nov 28, 2022
67e9211
Preserves existing behavior at /openapi but responds at /openapi/ui w…
tjquinno Nov 29, 2022
bb48d3c
Remove intermediate integrations project layer because we don't need …
tjquinno Nov 30, 2022
af58a7f
Doc revs; a bit of simplification in how OpenAPISupport delegates to …
tjquinno Nov 30, 2022
c43079f
Clean up the PR a bit
tjquinno Nov 30, 2022
3a88621
Revert inadvertent changes to SE quick-start
tjquinno Nov 30, 2022
90fb062
Add favicon; fix doc retrieval
tjquinno Nov 30, 2022
1cc042e
Adopt doc review comments
tjquinno Dec 1, 2022
3948355
Remove obsolete text describing simple HTML response - we're removed …
tjquinno Dec 1, 2022
2779d54
Clarify confusing text around dependencies
tjquinno Dec 1, 2022
d3bf68d
Change U/I -> UI in code (changed doc before)
tjquinno Dec 2, 2022
757bb8d
Change U/I to UI in code
tjquinno Dec 2, 2022
6a1eb68
Try to avoid intermittent timing-related test failures
tjquinno Dec 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,11 @@
<artifactId>helidon-microprofile-openapi</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.openapi-ui</groupId>
<artifactId>helidon-integrations-openapi-ui</artifactId>
<version>${helidon.version}</version>
</dependency>
<!-- CORS support -->
<dependency>
<groupId>io.helidon.webserver.cors</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ final class FeatureCatalog {
.experimental(true)
.nativeSupported(true)
.flavor(HelidonFlavor.SE));
add("io.helidon.integrations.openapi.ui",
FeatureDescriptor.builder()
.name("OpenAPI U/I")
.description("OpenAPI U/I integration")
.path("OpenAPI U/I"));
add("io.helidon.integrations.vault",
FeatureDescriptor.builder()
.name("HCP Vault")
Expand Down
1 change: 1 addition & 0 deletions docs/config/config_reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The following section lists all configurable types in Helidon.
- xref:{rootdir}/config/io_helidon_security_providers_oidc_common_OidcConfig.adoc[OidcConfig (security.providers.oidc.common)]
- xref:{rootdir}/config/io_helidon_security_providers_oidc_OidcProvider.adoc[OidcProvider (security.providers.oidc)]
- xref:{rootdir}/config/io_helidon_openapi_OpenAPISupport.adoc[OpenAPISupport (openapi)]
- xref:{rootdir}/config/io_helidon_openapi_OpenApiUi.adoc[OpenApiUi (openapi)]
- xref:{rootdir}/config/io_helidon_security_providers_common_OutboundConfig.adoc[OutboundConfig (security.providers.common)]
- xref:{rootdir}/config/io_helidon_security_providers_common_OutboundTarget.adoc[OutboundTarget (security.providers.common)]
- xref:{rootdir}/config/io_helidon_common_pki_KeyConfig_PemBuilder.adoc[PemBuilder (common.pki.KeyConfig)]
Expand Down
1 change: 1 addition & 0 deletions docs/config/io_helidon_openapi_OpenAPISupport.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Type: link:{javadoc-base-url}/io.helidon.openapi/io/helidon/openapi/OpenAPISuppo

|`cors` |xref:{rootdir}/config/io_helidon_webserver_cors_CrossOriginConfig.adoc[CrossOriginConfig] |{nbsp} |Assigns the CORS settings for the OpenAPI endpoint.
|`static-file` |string |`META-INF/openapi.*` |Sets the file system path of the static OpenAPI document file. Default types are `json`, `yaml`, and `yml`.
|`ui` |xref:{rootdir}/config/io_helidon_openapi_OpenApiUi.adoc[OpenApiUi] |{nbsp} |Assigns the OpenAPI UI builder the `OpenAPISupport` service should use in preparing the U/I.
|`web-context` |string |`/openapi` |Sets the web context path for the OpenAPI endpoint.

|===
Expand Down
57 changes: 57 additions & 0 deletions docs/config/io_helidon_openapi_OpenApiUi.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2022 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

///////////////////////////////////////////////////////////////////////////////

ifndef::rootdir[:rootdir: {docdir}/..]
:description: Configuration of io.helidon.openapi.OpenApiUi
:keywords: helidon, config, io.helidon.openapi.OpenApiUi
:basic-table-intro: The table below lists the configuration keys that configure io.helidon.openapi.OpenApiUi
include::{rootdir}/includes/attributes.adoc[]

= OpenApiUi (openapi) Configuration

// tag::config[]


Type: link:{javadoc-base-url}/io.helidon.openapi/io/helidon/openapi/OpenApiUi.html[io.helidon.openapi.OpenApiUi]


[source,text]
.Config key
----
ui
----



== Configuration options



.Optional configuration options
[cols="3,3a,2,5a"]

|===
|key |type |default value |description

|`enabled` |boolean |`true` |Sets whether the UI should be enabled.
|`options` |Map&lt;string, string&gt; |{nbsp} |Sets implementation-specific UI options.
|`web-context` |string |{nbsp} |web context (path) where the UI will respond

|===

// end::config[]
1 change: 1 addition & 0 deletions docs/config/io_helidon_openapi_SEOpenAPISupport.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ openapi
|`servers.operation.*` |string[&#93; |{nbsp} |Sets alternative servers to service the indicated operation (represented here by '*'). Repeat for multiple operations.
|`servers.path.*` |string[&#93; |{nbsp} |Sets alternative servers to service all operations at the indicated path (represented here by '*'). Repeat for multiple paths.
|`static-file` |string |`META-INF/openapi.*` |Sets the file system path of the static OpenAPI document file. Default types are `json`, `yaml`, and `yml`.
|`ui` |xref:{rootdir}/config/io_helidon_openapi_OpenApiUi.adoc[OpenApiUi] |{nbsp} |Assigns the OpenAPI U/I builder the `OpenAPISupport` service should use in preparing the U/I.
|`web-context` |string |`/openapi` |Sets the web context path for the OpenAPI endpoint.

|===
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/includes/attributes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ endif::[]
:version-plugin-jib: 0.10.1
:version-plugin-jandex: 1.0.6
:version-lib-micrometer: 1.6.6
:version-lib-smallrye-open-api: 2.1.16

:jdk-version: 17

Expand Down Expand Up @@ -204,6 +205,7 @@ endif::[]
:mp-tyrus-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.tyrus
:mp-restclient-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.restclient
:openapi-javadoc-base-url: {javadoc-base-url}/io.helidon.openapi
:openapi-ui-javadoc-base-url: {javadoc-base-url}/io.helidon.integrations.openapi.ui
:reactive-base-url: {javadoc-base-url}/io.helidon.common.reactive
:scheduling-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.scheduling
:security-integration-jersey-base-url: {javadoc-base-url}/io.helidon.security.integration.jersey
Expand Down Expand Up @@ -271,4 +273,7 @@ endif::[]
:openapi-generator-tool-generators-docs-url: {openapi-generator-tool-docs-url}/generators
:openapi-generator-tool-site-url: https://openapi-generator.tech

// OpenAPI UI
:smallrye-openapi-ui-base-url: https://github.com/smallrye/smallrye-open-api/tree/{version-lib-smallrye-open-api}/ui/open-api-ui

endif::attributes-included[]
2 changes: 1 addition & 1 deletion docs/includes/openapi/openapi-generator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ For the Maven plug-in, use elements within the `<configuration>` section of the
[source,xml]
----
<configuration>
<inputSpec>petstore.yaml</output>
<inputSpec>petstore.yaml</inputSpec>
</configuration>
----
* _additional properties_
Expand Down
200 changes: 200 additions & 0 deletions docs/includes/openapi/openapi-ui.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2022 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

///////////////////////////////////////////////////////////////////////////////

ifndef::rootdir[:rootdir: {docdir}/../..]
// Following make editing the included file a little easier
:flavor-lc: se
:flavor-uc: SE
:se-flavor:

// tag::preamble[]
:feature-name: Helidon OpenAPI UI support
:screen-capture-start: openapi-ui-screen-capture-greeting-{flavor-lc}-start.png
:screen-capture-expanded: openapi-ui-screen-capture-greeting-{flavor-lc}-expanded.png
// end::preamble[]

// tag::intro[]

== Contents

- <<Overview, Overview>>
- <<Maven Coordinates, Maven Coordinates>>
- <<Usage, Usage>>
- <<API, API>>
- <<Configuration, Configuration>>
- <<Additional Information, Additional Information>>

// end::intro[]

// tag::overview[]
== Overview

SmallRye offers an link:{smallrye-openapi-ui-base-url}[OpenAPI user interface component] which displays a web page based on your application's OpenAPI document.
Through that UI, users can invoke the operations declared in the document.
While not generally suitable for end-users, the OpenAPI UI can be useful for demonstrating and "test driving" your service's endpoints.

The Helidon OpenAPI component allows you to integrate the SmallRye UI into your application, adding the UI web page to your application very simply.


// end::overview[]

// tag::dependencies[]
include::{rootdir}/includes/dependencies.adoc[]

[source,xml,subs=+macros]
----
<dependency>
<groupId>io.helidon.integrations.openapi-ui</groupId>
<artifactId>helidon-integrations-openapi-ui</artifactId>
ifdef::mp-flavor[ <scope>runtime</scope>]
</dependency>
----

// end::dependencies[]

// tag::usage[]
// tag::usage-start[]
== Usage
ifdef::se-flavor[]
Make sure your application creates a Helidon `OpenAPISupport` instance and registers it for routing (described in detail in link:{openapi-page}[the Helidon OpenAPI documentation]). `OpenAPISupport` automatically prepares the OpenAPI UI with default settings if you also declare a dependency on the Helidon OpenAPI UI integration component as explained above. The <<API,API>> section below illustrates adding OpenAPI to your application and customizing the UI behavior.
endif::se-flavor[]

After you modify, build, and start your Helidon {flavor-uc} service, you can access the OpenAPI UI by default at `http://your-host:your-port/openapi/ui`.
Helidon also uses conventional content negotiation at `http://your-host:your-port/openapi` returning the UI to browsers (or any client that accepts HTML) and the OpenAPI document otherwise.

You can customize the path using
ifdef::se-flavor[either the API or ]
xref:Configuration[configuration].

The example below shows the UI
ifdef::se-flavor[]
if you modify the Helidon SE QuickStart greeting application to contain a static OpenAPI file which describes the service endpoints.
endif::se-flavor[]
ifdef::mp-flavor[]
for the Helidon MP QuickStart greeting application.
endif::mp-flavor[]

.OpenAPI UI Screen for Helidon {flavor-uc} QuickStart Greeting Application
image::{screen-capture-start}[align="center",title="Example OpenAPI UI Screen"]

// end::usage-start[]

// tag::usage-expanded-screen[]
With the OpenAPI UI displayed, follow these steps to access one of your service's operations.

. Find the operation you want to run and click on its row in the list.
. The UI expands the operation, showing any input parameters and the possible responses. Click the "Try it out" button in the operation's row.
. The UI now allows you to type into the input parameter field(s) to the right of each parameter name. Enter any required parameter values (first highlighted rectangle) and any non-required values you wish, then click "Execute" (highlighted arrow).
. Just below the "Execute" button the UI shows several sections: +
* the equivalent `curl` command for submitting the request with your inputs,
* the URL used for the request, and
* a new "Server response" section (second highlighted rectangle) containing several items from the response: +
** HTTP status code
** body
** headers

The next image shows the screen after you submit the "Returns a personalized greeting" operation.

Note that the UI shows the actual response from invoking the operation in the "Server response" section. The "Responses" section farther below describes the possible responses from the operation as declared in the OpenAPI document for the application.

.Example OpenAPI UI Screen
image::{screen-capture-expanded}[align="center",title="Example OpenAPI UI Screen"]

// end::usage-expanded-screen[]
// end::usage[]

// tag::config-intro[]
== Configuration
To use configuration to control how the Helidon OpenAPI UI service behaves, add an `openapi.ui` section to
ifdef::mp-flavor[your `META-INF/microprofile-config.properties` file.]
ifdef::se-flavor[your configuration file, such as `application.yaml`.]

include::{rootdir}/config/io_helidon_openapi_OpenApiUi.adoc[tag=config,leveloffset=+1]
The default UI `web-context` value is the web context for your `OpenAPISupport` service with the added suffix `/ui`. If you use the default web context for both `OpenAPISupport` and the UI, the UI responds at `/openapi/ui`.

// end::config-intro[]

// tag::config-details[]

You can use configuration to affect the UI path in two ways:

* Configure the OpenAPI endpoint path (the `/openapi` part).
+
Recall that you can xref:{openapi-page}#config[configure the Helidon OpenAPI component] to change where it serves the OpenAPI document.
+
.Configuring the OpenAPI web context
ifdef::se-flavor[]
[source,yaml]
----
openapi:
web-context: /my-openapi
----
endif::se-flavor[]
ifdef::mp-flavor[]
[source,properties]
----
openapi.web-context=/my-openapi
----
endif::mp-flavor[]
+
In this case, the path for the UI component is your customized OpenAPI path with `/ui` as a suffix.
With the example above, the UI responds at `/my-openapi/ui` and
Helidon uses standard content negotiation at `/my-openapi` to return either the OpenAPI document or the UI.
* Separately, configure the entire web context path for the UI independently from the web context for OpenAPI.
+
.Configuring the OpenAPI UI web context
ifdef::se-flavor[]
[source,yaml]
----
openapi:
ui:
web-context: /my-ui
----
endif::se-flavor[]
ifdef::mp-flavor[]
[source,properties]
----
openapi.ui.web-context=/my-ui
----
endif::mp-flavor[]
+
[NOTE]
====
The `openapi.ui.web-context` setting assigns the _entire_ web-context for the UI, not the suffix appended to the `OpenAPISupport` endpoint.
====
With this configuration, the UI responds at `/my-ui` regardless of the path for OpenAPI itself.

The SmallRye OpenAPI UI component accepts several options, but they are of minimal use to application developers and they must be passed to the SmallRye UI code programmatically.
Helidon allows you to specify these values using configuration in the `openapi.ui.options` section. Helidon then passes the corresponding options to SmallRye for you.
To configure any of these settings, use the enum values--they are all lower case--declared in the SmallRye link:{smallrye-openapi-ui-base-url}/src/main/java/io/smallrye/openapi/ui/Option.java[`Option.java`] class as the keys in your Helidon configuration.

[NOTE]
====
Helidon prepares several of the SmallRye options automatically based on other settings.
Any options you configure override the values Helidon assigns, possibly interfering with the proper operation of the UI.
====

// end::config-details[]

// tag::additional-info[]
== Additional Information

xref:{openapi-page}[Helidon OpenAPI {flavor-uc} documentation]

link:{smallrye-openapi-ui-base-url}[SmallRye OpenAPI UI GitHub site]
// end::additional-info[]
12 changes: 10 additions & 2 deletions docs/includes/openapi/openapi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ The SPI defines an interface you can implement in your application which can mas

// end::overview[]

// tag::mp-depc[]
<dependency>
<groupId>io.helidon.microprofile.openapi</groupId>
<artifactId>helidon-microprofile-openapi</artifactId>
<scope>runtime</scope>
</dependency>
// end::mp-depc[]

// tag::furnish-openapi-info[]

==== Furnish OpenAPI information about your endpoints
Expand Down Expand Up @@ -139,8 +147,8 @@ class name of your class.
Once you add the {flavor-uc} OpenAPI dependency to your
ifdef::mp-flavor[project,]
ifdef::se-flavor[project and add code to create the `OpenAPISupport` object to your routing,]
your application will automatically respond to the built-in endpoint --
`/openapi` -- and it will return the OpenAPI document describing the endpoints
your application automatically responds to the built-in endpoint --
`/openapi` -- and it returns the OpenAPI document describing the endpoints
in your application.

By default, per the MicroProfile OpenAPI spec, the default format of the OpenAPI document is YAML.
Expand Down
Loading