Skip to content

XML Example can't be generated if last property is an attribute #299

Description

@jweisman

Given the below pet.yaml definition, when the favorite property of the Tag object is defined first, the XML example is generated correctly. When the favorite property is last, the following error is thrown:

javax.xml.stream.XMLStreamException: Trying to write an attribute when there is no open start element.
	at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1584)
	at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1613)
	at com.ctc.wstx.sw.BaseNsStreamWriter.writeAttribute(BaseNsStreamWriter.java:231)
	at io.swagger.oas.inflector.examples.XmlExampleSerializer.writeTo(XmlExampleSerializer.java:160)
	at io.swagger.oas.inflector.examples.XmlExampleSerializer.writeTo(XmlExampleSerializer.java:81)
	at io.swagger.oas.inflector.examples.XmlExampleSerializer.writeTo(XmlExampleSerializer.java:135)
	at io.swagger.oas.inflector.examples.XmlExampleSerializer.writeTo(XmlExampleSerializer.java:81)
	at io.swagger.oas.inflector.examples.XmlExampleSerializer.serialize(XmlExampleSerializer.java:39)
	at MakeSwaggerExamples.main(MakeSwaggerExamples.java:61)
Exception in thread "main" java.lang.NullPointerException
	at java.io.StringReader.<init>(StringReader.java:50)
	at MakeSwaggerExamples.main(MakeSwaggerExamples.java:67)
Pet:
  type: object
  required:
    - name
    - photoUrls
  properties:
    id:
      type: integer
      format: int64
    category:
      $ref: './category.yaml#/Category'
    name:
      type: string
      example: doggie
    photoUrls:
      type: array
      xml:
        name: photoUrl
        wrapped: true
      items:
        type: string
    tag:
      type: array
      xml:
        name: tags
        wrapped: true
      items:
        $ref: '#/Tag'
        xml:
          name: tag
    status:
      type: string
      description: pet status in the store
      enum:
        - available
        - pending
        - sold
  xml:
    name: Pet
Tag:
  type: object
  properties:
    favorite:
      type: boolean
      xml:
        attribute: true
    id:
      type: integer
      format: int64
    name:
      type: string
  xml:
    name: tag       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions