swagger-api / swagger-api/swagger-codegen

Cannot use the /docs to verify API

Open
#10,121 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

#9786 ### Description

I am starting to use the swagger-codegen. I build and try to run the PetStore nodejs server sample.
The server is started correctly at HTTP://localhost:8080/. Anyway when I try to verify APi, there are two issues:

  1. On HTTP://localhost:8080/docs, choose one API, eg, /pet/1/uploadImage, it actually cannot specify anything for body. Similar to other API, you cannot specify the body also.
  2. When the requestBody is "multipart/form-data", even though I try to use other API testing tool(Eg, postman) to specify the body of API /pet/1/uploadImage, only "additionalMetadata" get all body input, while "file" and "petId" is empty for the controller method. Should the controller only has one parameter for whole body?
Swagger-codegen version

I am using latest code of branch 3.0.0.

Swagger declaration file content or url

I did not make a line of code change for the testing.

Command line used for generation
Steps to reproduce
  1. git clone -b 3.0.0 https://github.com/swagger-api/swagger-codegen
  2. cd swagger-codegen/samples/server/petstore/nodejs
  3. npm install
  4. npm start
  5. HTTP://localhost:8080/docs
  6. go to /pet/{id}/uploadImage API and cannot find way to specify body parameters.
  7. use postman to specify body parameters for same API, but controller does not accept multi body parameters.
Related issues/PRs
Suggest a fix/enhancement

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

Reproduce the problem from samples/server/petstore/nodejs by running npm install and npm start, then open the generated /docs entry for /pet/{id}/uploadImage. Inspect the generated controller handling that operation and compare its multipart/form-data behavior with the request sent from Postman. Done means the docs expose the body inputs and the controller receives file, petId, and additionalMetadata correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
api, backend
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.