widdershins
widdershins copied to clipboard
XML attributes not rendered correctly
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:
- Command-line:
node widdershins.js example.yaml -o example.md
- 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
- Error:
The XML attributes (
message
andaccessed
) are rendered as elements instead. Thexml: 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
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!