-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
From the openapi specification website:
Complex Serialization in Form Data
[...] For more complex scenarios, such as nested arrays or JSON in form data, you need to use the
contentTypekeyword to specify the media type for encoding the value of a complex field. Consider Slack incoming webhooks for an example. A message can be sent directly as JSON, or the JSON data can be sent inside a form field namedpayloadlike so (before URL-encoding is applied):payload={"text":"Swagger is awesome"}This can be described as:
openapi: 3.0.0 info: version: 1.0.0 title: Slack Incoming Webhook externalDocs: url: https://api.slack.com/incoming-webhooks servers: - url: https://hooks.slack.com paths: /services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX: post: summary: Post a message to Slack requestBody: content: application/json: schema: $ref: "#/components/schemas/Message" application/x-www-form-urlencoded: schema: type: object properties: payload: # <--- form field that contains the JSON message $ref: "#/components/schemas/Message" encoding: payload: contentType: application/json responses: "200": description: OK components: schemas: Message: title: A Slack message type: object properties: text: type: string description: Message text required: - text
Perhaps the ContentUnit struct could be extended to include a map field that maps property names to mime-type strings, and an Encoding function could be added to populate said map?
Metadata
Metadata
Assignees
Labels
No labels