OpenAPITools / OpenAPITools/openapi-generator

[BUG] java microprofile generating incorrect code

Open
#17,384 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

the interface did not generate a singleRequestParam. I hope this is sufficient enough information to demonstrate the issue.

openapi-generator version

7.1.0

OpenAPI declaration file content or url
        "parameters": [
            {
                "in": "query",
                "name": "NewParameter",
                "description": "New parameter",
                "required": "true",
                "schema": {
                    "": ""
                }
            },
            {
            "$ref": "#/components/parameters/X-Tenant"
          },
          {
            "$ref": "#/components/parameters/X-Correlation-ID"
          },
          {
            "in": "header",
            "name": "True-Client-IP",
            "description": "Contains the end user's IP extracted from X-Forwarded-For.",
            "schema": {
              "type": "string"
            },
            "required": false,
            "example": "127.0.0.1"
          },
          {
            "$ref": "#/components/parameters/Person-Email"
          },
          {
            "$ref": "#/components/parameters/Person-LoyaltyCard"
          },
          {
            "$ref": "#/components/parameters/Person-AltId"
          },
          {
            "$ref": "#/components/parameters/Person-Id"
          },
          {
            "$ref": "#/components/parameters/Alias-Key"
          },
          {
            "$ref": "#/components/parameters/Alias-Value"
          },
          {
            "name": "fields.customers",
            "in": "query",
            "description": "Specify the fields of customer that are expected to return. Provide any number of fields for the customer resource, separating them with commas.",
            "required": false,
            "examples": {
              "personId": {
                "value": "personId"
              },
              "aliasIds": {
                "value": "aliasIds"
              },
              "personalInfo": {
                "value": "personalInfo"
              },
              "loyaltyCards": {
                "value": "loyaltyCards"
              },
              "contactInfo": {
                "value": "contactInfo"
              },
              "createdDateTime": {
                "value": "createdDateTime"
              },
              "modifiedDateTime": {
                "value": "modifiedDateTime"
              },
              "versionKey": {
                "value": "versionKey"
              },
              "preferences": {
                "value": "preferences"
              },
              "Combination of fields": {
                "value": "name,loyaltyCards,contactInfo"
              }
            },
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include",
            "in": "query",
            "description": "Include returns details of a top-level resource requested.",
            "required": false,
            "examples": {
              "Profiles parameter": {
                "value": "profiles"
              },
              "Addresses parameter": {
                "value": "addresses"
              },
              "Groups parameter": {
                "value": "groups"
              }
            },
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields.profiles",
            "in": "query",
            "description": "Specify the fields of profiles expected to return by using the 'include=profiles' query parameter.",
            "required": false,
            "examples": {
              "Shopper details": {
                "value": "shopper"
              }
            },
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fields.groups",
            "in": "query",
            "description": "Specify the fields of groups expected to return by using the 'include=groups' query parameter.",
            "required": false,
            "examples": {
              "id": {
                "value": "id"
              },
              "aliasIds": {
                "value": "aliasIds"
              },
              "name": {
                "value": "name"
              },
              "type": {
                "value": "type"
              },
              "systemGenerated": {
                "value": "systemGenerated"
              },
              "modified": {
                "value": "modified"
              },
              "created": {
                "value": "created"
              },
              "versionKey": {
                "value": "versionKey"
              }
            },
            "schema": {
              "type": "string"
            }
          }
        ],
Generation Details
    default ResponseEntity<FetchCustomerResponse> fetchCustomer(
         @Valid @RequestParam(value = "fields.customers", required = false) String fieldsCustomers,
         @Valid @RequestParam(value = "include", required = false) String include,
         @Valid @RequestParam(value = "fields.profiles", required = false) String fieldsProfiles,
         @Valid @RequestParam(value = "fields.groups", required = false) String fieldsGroups
    ) {
Steps to reproduce
openApiGenerate {
    generatorName = "java"
    library = "microprofile"
    inputSpec = "$projectDir/src/main/resources/openapi.json".toString()
    outputDir = layout.buildDirectory.dir("generated/sources/openapi").get().toString()
    configOptions.putAll([
        openApiNullable          : "false",
        serializationLibrary     : "jackson",
        annotationLibrary        : "none",
        documentationProvider    : "none",
        useSingleRequestParameter: "true",
        implicitHeaders          : "true",
    ])
    typeMappings.putAll([
        // Override unsupported anyOf on metadata.value
        "MetadataDetailValue": "Object"
    ])

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Gradle openApiGenerate configuration in the issue, using the Java generator with the microprofile library and useSingleRequestParameter enabled. Reproduce the generation from the provided OpenAPI declaration and inspect the generated fetchCustomer interface; done means the reported single-request-parameter behavior is understood and corrected or the issue is clarified with a focused reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.