question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Encoding attribute is not respected on the request

See original GitHub issue

Q&A

  • OS: macOS
  • Browser: chrome
  • Version: 74
  • Method of installation: composer
  • Swagger-UI version: 3.10.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  title: 'Test Swagger'
  description: 'Test Swagger'
  contact:
    email: test@swagger.com
  version: '1'
paths:
  /api/v1/profile:
    post:
      tags:
        - Profile
      summary: 'profile of the user user'
      requestBody:
        description: 'Profile that needs to be stored'
        content:
          multipart/mixed:
            schema:
              properties:
                avatar_image:
                  description: avatar_image
                  type: file
                profile:
                  type: object
                  $ref: '#/components/schemas/Profile'
              type: object
            encoding:
              profile:
                contentType: application/json
      responses:
        201:
          description: 'Profile that was registered.'
          content:
            application/json:
              schema:
                type: object
        422:
          description: 'Unprocessable Entity.'
          content:
            application/json:
              schema:
                type: object
      security:
        -
          passport:
            - '*'
components:
  schemas:
    Profile:
      title: Profile
      description: 'profile model'
      required:
        - email
        - telephone
      properties:
        email:
          schema: Profile
          description: 'Email of the profile'
          type: string
        name:
          schema: Profile
          description: 'Name of the profile'
          type: string
      type: object
  securitySchemes:
    passport:
      type: oauth2
      description: 'Laravel passport oauth2 security.'
      in: header
      scheme: http
      flows:
        password:
          authorizationUrl: 'http://swagger.test/oauth/authorize'
          tokenUrl: 'http://swagger.test/oauth/token'
          refreshUrl: 'http://swagger.test/token/refresh'
          scopes: {  }
tags:
  -
    name: Profile
    description: 'Operations for the user profile'

Describe the bug you’re encountering

To reproduce…

Steps to reproduce the behavior:

  1. Fill the blanks for the /api/v1/profile request
  2. Make the request
  3. The requests sends the following payload:
------WebKitFormBoundaryaSzepCtBw5Aiaiue
Content-Disposition: form-data; name="avatar_image"; filename="the-avatar_image.png"
Content-Type: image/png


------WebKitFormBoundaryaSzepCtBw5Aiaiue
Content-Disposition: form-data; name="profile"

{
  "email": "myemail@test.com",
  "name": "my name"
}
------WebKitFormBoundaryaSzepCtBw5Aiaiue-- 

Expected behavior

The payload should be

------WebKitFormBoundaryaSzepCtBw5Aiaiue
Content-Disposition: form-data; name="avatar_image"; filename="the-avatar_image.png"
Content-Type: image/png


------WebKitFormBoundaryaSzepCtBw5Aiaiue
Content-Disposition: form-data; name="profile"
Content-Type: application/json
{
  "email": "myemail@test.com",
  "name": "my name"
}
------WebKitFormBoundaryaSzepCtBw5Aiaiue-- 

Check that the profile attribute contains it’s content-type as “application/json”.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:34
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
RomanOrlov2commented, Sep 5, 2020

Same issue, please solve it

0reactions
LouCastaldocommented, Nov 9, 2022

We are having same problem. Has this been resolved in SwaggerHub Cloud Enterprise ??

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accept-Encoding - HTTP - MDN Web Docs
The Accept-Encoding request HTTP header indicates the content encoding (usually a compression algorithm) that the client can understand.
Read more >
Indicating whether to encode inserted attribute values
When you insert an attribute value as a URL parameter, you can specify whether Studio encodes the value before inserting it into the...
Read more >
Do I really need to encode '&' as '&'? - Stack Overflow
Just as the error said, in HTML, attributes are #PCDATA meaning they're parsed. ... Specifically, if HTML5 does not require using & in...
Read more >
Cross Site Scripting Prevention - OWASP Cheat Sheet Series
Generally, attributes that accept JavaScript, such as onClick , are NOT safe to use with untrusted attribute values. Output Encoding for “JavaScript Contexts”¶....
Read more >
OpenAPI Specification - Version 3.0.3 - Swagger
This attribute is only applicable to multipart and application/x-www-form-urlencoded request bodies. Encoding Object. A single encoding definition applied to a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found