Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(http): respect Encoding Object while building requests #3078

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

char0n
Copy link
Member

@char0n char0n commented Aug 1, 2023

This change is specific to OpenAPI 3.x.y.

Refs swagger-api/swagger-ui#5356
Refs swagger-api/swagger-ui#4826
Refs #2954

Description

OpenAPI 3.x.y definition:

{
  "openapi": "3.0.0",
  "paths": {
    "/upload/": {
      "post": {
        "tags": [
          "upload"
        ],
        "operationId": "upload",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "options": {
                    "type": "object",
                    "properties": {
                      "some_array": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "max_bar": {
                        "type": "integer",
                        "default": 300
                      }
                    }
                  }
                }
              },
              "encoding": {
                "options": {
                  "contentType": "application/json; charset=utf-8"
                }
              }
            }
          }
        }
      }
    }
  }
}

Here is how the multipart/form-data request looked BEFORE:

POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266

-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="options"

{"some_array":["string"],"max_bar":300}

Here is how the multipart/form-data request looked AFTER:

POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266

-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="options"; filename="blob"
Content-Type: application/json

{"some_array":["string"],"max_bar":300}

Every boundary now contains specific Content-Type header if defined. Note that filename is also present in every Content-Disposition header and always contains value of blob. This inclusion of filename cannot be avoided as this is the only way how to assign specific Content-Type for every boundary.

Motivation and Context

Allow to send Content-Type header with every boundary within multipart/form-data request.

Types of changes

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@swagger-bot
Copy link
Contributor

🎉 This PR is included in version 3.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants