OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.45k stars 6.49k forks source link

[BUG] java microprofile generating incorrect code #17384

Open caleb-cushing0-kr opened 9 months ago

caleb-cushing0-kr commented 9 months ago
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"
    ])
martin-mfg commented 8 months ago

Hi, to reproduce this issue, could you please provide an input spec that is complete, minimal and valid? Thank you!