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

[JAVA] requestBody's with multiple options for content generate duplicate methods in Java classes #11848

Open
carlisom opened this issue Aug 4, 2022 · 4 comments

Comments

@carlisom
Copy link

carlisom commented Aug 4, 2022

Description

Swagger-codegen is generating duplicate methods in a class when multiple request bodies are defined. This seems to only happen when the title and/or description is included in the scheme for the request body.

error output on packaging

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/cisom/dev/workspace/swagger-codegen/samples/src/main/java/com/sample/api/DefaultApi.java:[183,37] method postDataCall(java.lang.Object,com.sample.ProgressResponseBody.ProgressListener,com.sample.ProgressRequestBody.ProgressRequestListener) is already defined in class com.sample.api.DefaultApi
[ERROR] /Users/cisom/dev/workspace/swagger-codegen/samples/src/main/java/com/sample/api/DefaultApi.java:[225,38] method postDataValidateBeforeCall(java.lang.Object,com.sample.ProgressResponseBody.ProgressListener,com.sample.ProgressRequestBody.ProgressRequestListener) is already defined in class com.sample.api.DefaultApi
[ERROR] /Users/cisom/dev/workspace/swagger-codegen/samples/src/main/java/com/sample/api/DefaultApi.java:[246,17] method postData(java.lang.Object) is already defined in class com.sample.api.DefaultApi
[ERROR] /Users/cisom/dev/workspace/swagger-codegen/samples/src/main/java/com/sample/api/DefaultApi.java:[257,30] method postDataWithHttpInfo(java.lang.Object) is already defined in class com.sample.api.DefaultApi
[ERROR] /Users/cisom/dev/workspace/swagger-codegen/samples/src/main/java/com/sample/api/DefaultApi.java:[270,37] method postDataAsync(java.lang.Object,com.sample.ApiCallback<java.lang.Void>) is already defined in class com.sample.api.DefaultApi
Swagger-codegen version

3.0.34 and 3.0.35-SNAPSHOT

Swagger declaration file content or url

sample.yaml

openapi: 3.0.2
info:
  title: Sample Service
  version: '1.0'
  description: Sample yaml file to recreate bug
servers:
  - url: 'http://127.0.0.1'
    description: local
paths:
  /sample/v1/paths:
    post:
      summary: post to path
      operationId: post_data
      responses:
        '200':
          description: received
      description: Send data to the Sample Service
      requestBody:
        content:
          sample.com/syslog:
            schema:
              type: string
              title: SysSysloglog
              description: "Syslog messages separated by `\\n`"
              format: binary
          sample.org/unified:
            schema:
              type: string
              title: Unified
              description: "Unified records"
              format: binary
        description: 'Request Body'
        required: true

config file

{
  "apiPackage": "com.sample.api",
  "modelPackage": "com.sample.model",
  "invokerPackage": "com.sample",
  "useRuntimeException": "true",
  "java11": "true",
  "parcelableModel": "false"
}
Command line used for generation
swagger-codegen generate -i sample.yaml -l java -c config.json
Steps to reproduce

Copy the sample.yaml and config.json below and run the following command.

swagger-codegen generate -i sample.yaml -l java -c config.json

Once generated mnv package will generate the error above showing the duplicate methods in the class.

Related issues/PRs

N/A

Suggest a fix/enhancement

Please fix this to allow title and description to be added to the schema of multiple request bodies.

@dacr
Copy link

dacr commented Dec 13, 2022

we have exactly the same issue

@manoj14581
Copy link

@carlisom We are facing the same issue, did you get any solution?

@aabdelli03
Copy link

is there any solution plzz ?? i'm blocked with that

@b-smets
Copy link

b-smets commented Dec 30, 2024

+1 on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants