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

multipart/form-data ui missing schema view #5125

Open
hoermannpaul opened this issue Jun 6, 2024 · 0 comments
Open

multipart/form-data ui missing schema view #5125

hoermannpaul opened this issue Jun 6, 2024 · 0 comments

Comments

@hoermannpaul
Copy link

hoermannpaul commented Jun 6, 2024

Q&A (please complete the following information)

  • OS: macOS
  • Browser: safari
  • Version: 17.5
  • Method of installation: online
  • Swagger-Editor version: latest to date
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Using online editor (or local spring boot swagger UI installation) with following definition:

openapi: 3.0.3
info:
  title: Some demo API
  version: 0.1.0
paths:
  /somepath:
    post:
      summary: "test"
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties: # Request parts
                id:
                  type: string
                  format: uuid
                address:
                  type: object
                  properties:
                    street:
                      type: string
                    city:
                      type: string
                profileImage:
                  type: string
                  format: base64
            encoding:
              profileImage:
                contentType: image/png, image/jpeg
      responses:
        '200':
          description: OK

Swagger-Editor configuration options: doesn't apply (online editor defaults)

Describe the bug you're encountering

Content header is not properly set as default for objects in multipart resquests.

To reproduce...

Steps to reproduce the behavior:

  1. Paste provided def into editor
  2. Click on endpoint (expand view)
    Shouldn't there be something to view schema (next to example data button) like displayed in figure 1? It's missing as seen in figure 2.
  3. If you hit execute now, following curl command is suggested (which doensn't work with generated java code):
curl -X 'POST' \
  'https://editor.swagger.io/somepath' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "address": {
    "street": "string",
    "city": "string"
  },
  "profileImage": "string"
}'

Where I expect:

curl -X 'POST' \
  'https://editor.swagger.io/somepath' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "address": {
    "street": "string",
    "city": "string"
  },
  "profileImage": "string"
};type=application/json'

Expected behavior

Executing curl command fails because default content-type is application/octet-stream, which is rejected by a properly configured REST Api.
Further, I'd expect a schema view for request body, which works if just changing 'multipart/form-data' to 'application/json' in given definition. Adding encoding for parameter manually adds correct header.

Screenshots

figure 1

figure 2

Additional context or thoughts

Maybe related to #4609

@hoermannpaul hoermannpaul changed the title multipart/form-data ui missing schema view & ignoring specified Content-Type multipart/form-data ui missing schema view Jun 10, 2024
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

1 participant