scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.43k stars 226 forks source link

File upload not rendering #185

Closed mebibou closed 2 years ago

mebibou commented 4 years ago

I am using swagger-jsdoc to define my swagger paths and on one particular endpoint I need to do file upload. The swagger doc looks like this:

/**
 * @swagger
 *
 * paths:
 *   /files:
 *     post:
 *       summary: Upload files for processing
 *       requestBody:
 *         required: true
 *         content:
 *           multipart/form-data:
 *             schema:
 *               type: object
 *               properties:
 *                 file:
 *                   type: array
 *                   items:
 *                     type: string
 *                     format: binary
 *       responses:
 *         200:
 *           $ref: '#/components/responses/NoContent'
 *         401:
 *           $ref: '#/components/responses/UnauthorizedError'
 *         500:
 *           $ref: '#/components/responses/UnexpectedError'
 */

When I hit "Try It Out" in swagger UI, I have a warning in the console Could not find component: JsonSchema_string_binary and the UI does not show an input to choose files:

Screen Shot 2020-05-17 at 9 33 34 AM

BePo65 commented 4 years ago

Oh, i do also wait for the solutuion to this problem.

I think that this is the known problem solved in swagger-api/swagger-ui issue #4600 . To transfer this solution to this package here, the dependeny 'swagger-ui-dist' should be updated to v3.26.0 (the latest release).

mebibou commented 4 years ago

@BePo65 thanks, npm install swagger-ui-dist@latest will work for now until a new release with update dist is available

KeitelDOG commented 3 years ago

Is this solved? Cause I'm using latest version"swagger-ui-express": "^4.1.6" and it still does not parse files correctly.

Should I add swagger-ui-dist@latest while waiting?

EDIT - I just checked in 4.1.6 package, and it's not released yet with "swagger-ui-dist": "^3.26.0", it's still on "swagger-ui-dist": "^3.18.1".

scottie1984 commented 2 years ago

Please use npm install --save swagger-ui-dist@latest

When installing swagger-ui-express it will pull in the latest version of swagger-ui-dist.

NaturalAI-InspireXT commented 1 year ago

This problem still persists, with the following packages

{ "swagger-jsdoc": "^6.0.8", "swagger-ui-express": "^4.1.6" }