swagger-api / swagger-api/swagger-codegen

Try out returns status code other than 200 in most of the operations in spring application generated using swagger spec.

Open
#6,287 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

when i generate a server stub for spring application using swagger spec in that three operations are listed with responses. On deployment of generated spring server stub either on embedded container or anywhere list down all operations correctly but when i try out those operations it throw 415 status code in most of the cases.

Swagger-codegen version

swagger-codegen-2.2.2.jar

Swagger declaration file content or url

https://gist.github.com/AkhtarShahid/23fde58f6354436bc2a1eabd0b1b7899

Command line used for generation

uploaded yaml file given in link in swagger editor and generated spring application.
Imported the project in eclipse and run mvn clean install to generate jar file.
Used jar to run on embedded container.

Steps to reproduce
  1. Upload attached yaml file in swagger editor and generate spring application.
  2. run mvn clean install in root directory of downloaded project.
  3. run java -jar target/.jar to run application on embedded server.
  4. fire root url and append context path from application.properties to make UI up.
  5. Operation will be listed in UI.
  6. Try out any of these operations by passing an image file as jpeg or png.
  7. Response should be 200 but it is 415.
Related issues/PRs
Suggest a fix/enhancement

yaml content has below data in it
parameters:
- name: files
in: formData
type: file

if i change the files in field value of name to file then it works for one operation. Or if i change all interface generated in api package where file is being used as RequestBody to files then it works.

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 linked Swagger declaration and reproduce the generated Spring application using the stated mvn clean install and embedded-container steps. Inspect the generated interfaces in the api package where the uploaded file is used as a RequestBody, then verify the operations accept JPEG or PNG input and return 200 rather than 415.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.