Skip to content

Instantly share code, notes, and snippets.

@fehguy
Last active December 28, 2016 01:56
Show Gist options
  • Save fehguy/e7c6881c7273fc11d9a7e6be8024bdda to your computer and use it in GitHub Desktop.
Save fehguy/e7c6881c7273fc11d9a7e6be8024bdda to your computer and use it in GitHub Desktop.

Supporting multipart/mixed Content-Type

To support multipart-mixed content types, we need to introduce another level of content in the requestBody definition. In the example below, we are defining a requestBody type of multipart/mixed and inside the content definition, we have multiple content types, one for each Content-Type.

This syntax only makes any sense under the multipart/mixed content type but may be help simplify multipart/form-data and possibly mulitpart/related and multipart/alternative, if we choose to support those.

paths:
  /test:
    post:
      operationId: getValues
      parameters: []
      requestBody:
        content:
          multipart/mixed:
            content:
              # text plain values
              'text/plain; charset=us-ascii':
                schema:
                  type: object
                  properties:
                    id:
                      type: integer
                      format: int32
                example: 42
              # JSON values
              application/json:
                schema:
                  address:
                    // json!
                    type: object
                    properties:
                      street:
                        type: string
                example: |
                  {
                    "street": "12345 El Monte Blvd"
                  }
              # Text file
              'text/plain; Content-Disposition: attachment;':
                schema:
                  type: string
                example: 'all these things, in file'
              # Image file
              image/jpeg:
                schema:
                  type: file
                example: 'iVBORw0KGgoAAAANSUhEUgAAAMAAAABICAYAAACgP/qyAAAMFmlDQ1BJQ0MgUHJvZmlsZQAASImVVwdUk8kWnr+kEJJQAhGQEnoTpFfpXRCQDjZCEiCUAAlBxY4sKrh2sWBFV0EUXQsga0UUC4uAvT4QUVlZFwtYUHmTArq+dt49Z/75cufeO9+d3JkzA4CSDTs3NwtVBiBbkC+MCvJlJSQmsUhdgApUgTKgA1U2R5TrExkZBqCM9n+XodsAkfQ3rCSx/nX8v4oKlyfiAIBEQpzCFXGyIT4OAK7ByRXmA0BohXrD2fm5EjwAsZoQEgSAiEtwmgxrSHCKDE+Q2sRE+UHsDQCZymYL0wCgS3izCjhpMA5dwtFGwOULIN4GsScnnc2F+CHEE7KzcyBWIkNslvJdnLS/xUwZi8lmp41hWS5SIfvzRblZ7Ln/53L8b8nOEo/OYQAbNV0YHCXJGa5bVWZOqARTIT4lSAmPgFgV4st8rtRegu+ni4Nj5fb9HJEfXDPABAAFXLZ/KMTaEDPFmbE+cmzHFkp9oT0azs8PiZHjFGFOlDw+WiDICg+Tx1mezgsZxTt4ooDoUZtUfmAIxLDS0OOF6THxMp5ocwE'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment