Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-6564

[SW]: OpenAPI Yaml Operation ID requires special Handling in Function Defitions

XMLWordPrintable

    • False
    • False
    • 2022 Week 32-34 (from Aug 8), 2022 Week 35-37 (from Aug 29)

      I have noticed that OpenAPI Documents and their Operation IDs are not directly consumable within SW Function blocks when they do not use CamelCase.

      Eg. The Github Open API Doc: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml

      Has the operation Id: 

      operationId: users/get-by-username

      Using this in the Function Definition, throws an error :

      FUNCTION BLOCK:
      ---
      functions:  
      - name: sendCallToApi    
        operation: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml#users/get-by-username
      
      ---
      ERROR:
      ---
      Caused by: java.lang.IllegalArgumentException: Required Operations [users/get-by-username] not found in the processed spec api.github.com.yaml. Available operations are [actionsGetGithubActionsPermissionsOrganization, actionsSetGithubActionsPermissionsOrganization
      ...
       usersGetByUsername, usersListFollowersForUser, usersListFollowingForUser, usersCheckFollowingForUser, usersListGpgKeysForUser, usersGetContextForUser, usersListPublicKeysForUser]
          at org.kie.kogito.codegen.openapi.client.generator.KogitoJavaClientCodegen.processGeneratedOperations(KogitoJavaClientCodegen.java:89)
          at org.kie.kogito.codegen.openapi.client.generator.OpenApiClientGeneratorWrapper.generate(OpenApiClientGeneratorWrapper.java:101)
          at org.kie.kogito.codegen.openapi.client.OpenApiClientCodegen.lambda$internalGenerate$6(OpenApiClientCodegen.java:120)

      And so, from the error we have to specify the operation Id in the Function to be:

      ...api.github.com.yaml#usersGetByUsername 

      This means that there is an additional step that the SW Yaml creator has to go through to convert the Operation ID from the OpenAPI doc to meet the CamelCase used by the Parsers in Kogito.

       

      Expected Behavior:

      • The OperationID is directly consumable within the SW Yaml

              cnicolai@redhat.com Cristiano Nicolai (Inactive)
              prattyush.mangal@ibm.com Prattyush Mangal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: