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

[BUG] [JAVA] Missing allowed enum values of query parameters #20487

Open
4 of 6 tasks
marcomartino22 opened this issue Jan 16, 2025 · 0 comments
Open
4 of 6 tasks

[BUG] [JAVA] Missing allowed enum values of query parameters #20487

marcomartino22 opened this issue Jan 16, 2025 · 0 comments

Comments

@marcomartino22
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Running the following command, the interface classes created don't contain the list of allowed values of the enum parameters in query string.

java -jar openapi-generator-cli-7.10.0.jar generate -i swaggerAnagrafe.yaml -g spring --api-package it.realeites.anagrafe.api --model-package it.realeites.anagrafe.model --group-id it.realeites.anagrafe --artifact-id APIAnagrafeRealeItes --artifact-version 1.0 -o APIAnagrafeRealeItes-SERVER --openapi-normalizer REF_AS_PARENT_IN_ALLOF=true,REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true --skip-validate-spec --additional-properties=useSpringBoot3=true,java.version=21

You can find below a portion of my swagger file containing a GET API with an enum query param (codiceCompagnia) and also the java code generated. As you can see the allowed values of the param codiceCompagnia (RMA and ITA) are not described in the java code.

Java code generated

    default ResponseEntity<RispostaAmministratoreCondomini> elencoCondominiV10(@NotNull @Parameter(name = "codiceCompagnia", description = "Codice della compagnia", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "codiceCompagnia", required = true) String codiceCompagnia) {

The right code should something like this: I have only add the string ", in = ParameterIn.QUERY,schema=@Schema(allowableValues={ "RMA", "ITA" })" after the parameter "required = true".

public ResponseEntity<RispostaAmministratoreCondomini> elencoCondominiV10(@NotNull @Parameter(name = "codiceCompagnia", description = "Codice della compagnia", required = true, in = ParameterIn.QUERY,schema=@Schema(allowableValues={ "RMA", "ITA" })) @Valid @RequestParam(value = "codiceCompagnia", required = true) String codiceCompagnia) {

This issue does not trigger the check of the value entered in the input parameter.

openapi-generator version

7.11.0

OpenAPI declaration file content or url
  /condomini/v1.0:
    get:
      description: Restituisce l'elenco dei condomini associati all'amministratore
      operationId: elencoCondomini_v10
      parameters:
      - name: canale
        in: query
        description: Canale di richiamo del servizio
        required: true
        schema:
          type: string
      - name: codiceCompagnia    
        in: query
        description: Codice della compagnia
        required: true
        schema:
          type: string
          enum:
          - RMA
          - ITA
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant