widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

XML attributes not rendered correctly

Open anne17 opened this issue 5 years ago • 1 comments

Describe the bug XML attributes in schemas marked with xml: attribute: true are currently rendered as elements instead of attributes of their parent. This syntax is valid in OpenAPI 3.0.0.

  • [x] - I have checked that my input document is valid OpenAPI 3.0.x

To Reproduce Steps to reproduce the behavior:

  1. Command-line:
node widdershins.js example.yaml -o example.md
  1. My input file (example.yaml):
openapi: "3.0.0"
info:
  title: Example
servers:
  - url: https://example.com
paths:
  /status:
    get:
      summary: Status
      responses:
        '200':
          description: Status response.
          content:
            application/xml:
              schema:
                $ref: "#/components/schemas/status"
components:
  schemas:
    status:
      type: object
      properties:
        build:
          type: object
          properties:
            message:
              type: string
              example: Done
              xml:
                attribute: true
            accessed:
              type: string
              example: "2018-05-11 18:29:57"
              xml:
                attribute: true
  1. Error: The XML attributes (message and accessed) are rendered as elements instead. The xml: attribute: true bit seems to be ignored by widdershins. The markdown looks like this (from line 168 in example.md):
<?xml version="1.0" encoding="UTF-8" ?>
<status>
  <build>
    <message>Done</message>
    <accessed>2018-05-11 18:29:57</accessed>
  </build>
</status>

Expected behavior This is what the markdown should look like (and this is also the output given by http://editor.swagger.io):

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <build message="Done" accessed="2018-05-11 18:29:57">
  </build>
</status>

Versions:

  • Node.js: v10.6.0

anne17 avatar Oct 05 '18 09:10 anne17

Note to self: need a mechanism to prefix properties which should be attributes with @ (which jgeXml is currently expecting to be there), or teach jgeXml to directly read an OAS-style schema object... Cannot be delegated to openapi-sampler as the examples may be taken as-is from the OAS document.

Thanks for flagging this up!

MikeRalphson avatar Oct 05 '18 09:10 MikeRalphson