Questo contenuto non è disponibile nella lingua selezionata.
Chapter 2. Configuring OpenAPI services endpoints
serverless logic uses the kogito.sw.operationIdStrategy property to generate the REST client for invoking services defined in OpenAPI documents. This property determines how the configuration key is derived for the REST client configuration.
The kogito.sw.operationIdStrategy property supports the following values: FILE_NAME, FULL_URI, FUNCTION_NAME, and SPEC_TITLE.
FILE_NAMEserverless logic uses the OpenAPI document file name to create the configuration key. The key is based on the file name, where special characters are replaced with underscores.
Example configuration:
quarkus.rest-client.stock_portfolio_svc_yaml.url=http://localhost:8282/1 - 1
- The OpenAPI file path is
<project_application_dir>/specs/stock-portfolio-svc.yaml. The generated key that configures the URL for the REST client isstock_portfolio_svc_yaml.
FULL_URIserverless logic uses the complete URI path of the OpenAPI document as the configuration key. The full URI is sanitized to form the key.
Example for Serverless Workflow
{ "id": "myworkflow", "functions": [ { "name": "myfunction", "operation": "https://my.remote.host/apicatalog/apis/123/document" } ] }Example configuration:
quarkus.rest-client.apicatalog_apis_123_document.url=http://localhost:8282/1 - 1
- The URI path is
https://my.remote.host/apicatalog/apis/123/document. The generated key that configures the URL for the REST client isapicatalog_apis_123_document.
FUNCTION_NAMEserverless logic combines the workflow ID and the function name referencing the OpenAPI document to generate the configuration key.
Example for Serverless Workflow
{ "id": "myworkflow", "functions": [ { "name": "myfunction", "operation": "https://my.remote.host/apicatalog/apis/123/document" } ] }Example configuration:
quarkus.rest-client.myworkflow_myfunction.url=http://localhost:8282/1 - 1
- The workflow ID is
myworkflow. The function name ismyfunction. The generated key that configures the URL for the REST client ismyworkflow_myfunction.
SPEC_TITLEserverless logic uses the
info.titlevalue from the OpenAPI document to create the configuration key. The title is sanitized to form the key.Example for OpenAPI document
openapi: 3.0.3 info: title: stock-service API version: 2.0.0-SNAPSHOT paths: /stock-price/{symbol}: ...Example configuration:
quarkus.rest-client.stock-service_API.url=http://localhost:8282/1 - 1
- The OpenAPI document title is
stock-service API. The generated key that configures the URL for the REST client isstock-service_API.
2.1. Using URI alias Copia collegamentoCollegamento copiato negli appunti!
As an alternative to the kogito.sw.operationIdStrategy property, you can assign an alias to a URI by using the workflow-uri-definitions custom extension. This alias simplifies the configuration process and can be used as a configuration key in REST client settings and function definitions.
The workflow-uri-definitions extension allows you to map a URI to an alias, which you can reference throughout the workflow and in your configuration files. This approach provides a centralized way to manage URIs and their configurations.
Prerequisites
- You have access to an serverless logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
- You have access to the OpenAPI specification files.
Procedure
Add the
workflow-uri-definitionsextension to your workflow. Within this extension, create aliases for your URIs.Example workflow
{ "extensions": [ { "extensionid": "workflow-uri-definitions",1 "definitions": { "remoteCatalog": "https://my.remote.host/apicatalog/apis/123/document"2 } } ], "functions": [3 { "name": "operation1", "operation": "remoteCatalog#operation1" }, { "name": "operation2", "operation": "remoteCatalog#operation2" } ] }
- 1
- Set the extension ID to
workflow-uri-definitions. - 2
- Set the alias definition by mapping the
remoteCatalogalias to a URI, for example,https://my.remote.host/apicatalog/apis/123/documentURI. - 3
- Set the function operations by using the
remoteCatalogalias with the operation identifiers, for example,operation1andoperation2operation identifiers.In the
application.propertiesfile, configure the REST client by using the alias defined in the workflow.Example property
quarkus.rest-client.remoteCatalog.url=http://localhost:8282/In the previous example, the configuration key is set to
quarkus.rest-client.remoteCatalog.url, and the URL is set tohttp://localhost:8282/, which the REST clients use by referring to theremoteCatalogalias.In your workflow, use the alias when defining functions that operate on the URI.
Example Workflow (continued):
{ "functions": [ { "name": "operation1", "operation": "remoteCatalog#operation1" }, { "name": "operation2", "operation": "remoteCatalog#operation2" } ] }