twskj / pretty-swag

Pretty UI for Swagger spec
MIT License
122 stars 20 forks source link

File is not rendering properly #37

Closed lolobosse closed 7 years ago

lolobosse commented 7 years ago

Hi there,

First of all thanks for this lib, it's amazing and waaaay better than everything in swagger-codegen.

However, the file type in multipart creates a text field...

Did I miss something?

See here:

image

Here is my endpoint:

paths:
  /pdf:
    post:
      summary: Converts a new document to PDF
      description: Max upload = 10 MB
      consumes:
        - multipart/form-data
      produces:
        - application/pdf
      parameters:
        - in: formData
          name: file
          type: file
          description: The file to upload.
      responses:
        '200':
          description: Conversion went successfully
          schema:
            type: file
        '400':
          description: Invalid input
twskj commented 7 years ago

Thanks for reporting. I got it running on my local, but let me test a bit more. :-)

lolobosse commented 7 years ago

Hey,

Yeah, I think you need to mod your rendering library a bit and then you should have it :)

I have not that much time to do it but I guess that you just need to change this line:

https://github.com/twskj/livedoc/blob/master/livedoc.js#L181 to accept a file type :) (however the layout will look shit, you may need a hidden button strategy 😉 ).

twskj commented 7 years ago

It's a little more than that. Additionally, on ajax call, I gotta add a few lines to handle multi-part/form data. And rendering the preview body a bit.

lolobosse commented 7 years ago

Hmm yeah ok I see :)

Also, I have a PDF as response, could be nice to handle that in an iframe but that's really a specific use-case. (I could implement it if needed)

twskj commented 7 years ago

We can open a separate issue to discuss this. ;-)

twskj commented 7 years ago

Finally get it out the door but still debating whether I should include the upload data into the preview pane or not. I'll leave it out for now just because when the file is getting too big it's just gonna become a liability than a help. Check it out and let me know.

twskj commented 7 years ago

I'll close for now. Feel free if you find it's not working for you