Encoding attribute is not respected on the request
See original GitHub issueQ&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:
- Fill the blanks for the /api/v1/profile request
- Make the request
- 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:
- Created 4 years ago
- Reactions:34
- Comments:12 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same issue, please solve it
We are having same problem. Has this been resolved in SwaggerHub Cloud Enterprise ??