Skip to content

XML support #300

@hiddewie

Description

@hiddewie

This is a feature request.

We have the following OpenAPI document:

# ... metadata
paths:
  /api/path:
    post:
      summary: ...
      description: ...
      operationId: operation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Model'
          application/xml:
            schema:
              $ref: '#/components/schemas/Model'
      responses:
        # ...

The model contains an xml key to describe the XML tag which is used to instantiate the model.

components:
  schemas:
    Model:
      xml:
        name: model
      type: object
      properties:
        # ...

Then, we fire an XML request, but this fails the validation

# ./spec/controllers/api/...'
# ------------------
# --- Caused by: ---
# OpenAPIParser::ValidateError:
#   #/components/schemas/Model expected object, but received String: <?xml version="1.0" encoding="UTF-8"?>
#   <model>
#     <property>94cf1162-0897-42f9-9dcb-9bd9abe7aa17</property>
#   </model>
#   ./spec/controllers/api/...

The XML is returned correctly, and matches the OpenAPI specification. The request validator interprets the XML response (application/xml content type) as a String.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions