swagger-api / swagger-js

Javascript library to connect to swagger-enabled APIs via browser or nodejs
http://swagger.io
Apache License 2.0
2.62k stars 758 forks source link

POST application/xml doesn't work #1647

Open andrew-mclachlan opened 4 years ago

andrew-mclachlan commented 4 years ago

https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-3/832/io.swagger.codegen.v3$swagger-codegen-cli/artifact/io.swagger.codegen.v3/swagger-codegen-cli/3.0.21-SNAPSHOT/swagger-codegen-cli-3.0.21-SNAPSHOT.jar

Generated nodejs-server from the above build.

/foo/config:
    post:
      tags:
      - Foo
      summary: config info.
      description: Send config info.
      operationId: config_info
      requestBody:
        description: Configuration Information
        content:
          application/xml:
            schema:
              $ref: '#/components/schemas/Some_Configuration'
        required: true
      responses:
        "200":
          description: Success. Some Configuration Information received.
          content: {}
        "400":
          description: Failure. Some Configuration Information could not be processed.
          content: {}
        "500":
          description: Server error.
          content: {}
      x-swagger-router-controller: Foo
      x-codegen-request-body-name: body

Expected behaviour: XML is passed to the server and can be processed. undefined is received.

andrew-mclachlan commented 4 years ago

The issue seems to lie in the schema. If it's a plain "string", then you get invalid XML in the Online doc, but you can send in the XML. If you have a "proper" schema, then it fails to send.

andrew-mclachlan commented 4 years ago

type: "object" for the schema seems to cause a problem.