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

File upload ui dialog? #51

Open
jessekrubin opened this issue Oct 28, 2020 · 2 comments
Open

File upload ui dialog? #51

jessekrubin opened this issue Oct 28, 2020 · 2 comments

Comments

@jessekrubin
Copy link

I am wondering how to get the swagger-ui for my server let me do an 'upload-file' request/form. Any ideas or suggestions? I have gotten this type of thing to work in non-js projects that have swagger docs before.

@SkeLLLa
Copy link
Owner

SkeLLLa commented Dec 10, 2020

Hi. It's quiet hard to achieve that, since it requires to apply some hacks to fastify schema.
That how I did that in fastify v2, but maybe it's also something the same in fastify v3. In your route for file upload:

schemaCompiler: (_schema) => {
        return function() {};
      },
      schema: {
        description: `create new file`,
        tags: ['files'],
        summary: 'create file',
        consumes: ['multipart/form-data'],
        security: [ ],
        body: {
          type: 'object',
          properties: {
            file: {
              type: 'string',
              format: 'binary',
            },
            language: {
              type: 'string',
              description: 'file language code',
              enum: langs.codes('1'),
            },
          },
        },

@jessekrubin
Copy link
Author

@SkeLLLa Thanks for getting back to me.

Unfortunately that does not work. The swagger ui still displays the input as if it is JSON.

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

2 participants