swagger-api / swagger-api/swagger-codegen

[java][feign] Bug generating optional fields, params are not optional in feign tested in 2.3.0 and 2.3.1

Open
#8,050 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The following definition (this is not the full definition but only the related part)

  '/projects':
    get:
      tags:
        - Project Management
      summary: Get project list
      parameters:
        - name: status
          in: query
          required: false
          type: string
          description: "Filter on project status [Created, Ready, Started]"
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/ProjectList'`

should generated a method without the status query and one/multiple with the status query but the one without is not generated

Swagger-codegen version

Tested with 2.3.0 and 2.3.1

Swagger declaration file content or url

See description

Command line used for generation

java -jar swagger-codegen-cli.jar
generate -i rest-api.yaml --api-package com.bla.client
--model-package com.bla.model --invoker-package com.bla.client.invoker --group-id com.bla--artifact-id spring-swagger-codegen-api-client --artifact-version 0.0.1-SNAPSHOT -l java --library feign -o example

Steps to reproduce

Create the client from swagger with an optional query field.

Related issues/PRs

3665 same issue but then for scala

Suggest a fix/enhancement

Create the client method without the parameter

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 provided Swagger definition and run the stated swagger-codegen-cli.jar command using the Java Feign library. Compare the generated client methods for the optional status query parameter with the expected method without that parameter, and verify the behavior against the related Scala issue 3665.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, 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.