Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jweisman opened this issue Mar 4, 2019 · 2 comments
Open

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

jweisman opened this issue Mar 4, 2019 · 2 comments

Comments

@jweisman
Copy link
Contributor

jweisman commented Mar 4, 2019

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       
@gracekarina
Copy link
Contributor

hi @jweisman which version of openapi are you using, if you can share the full spec will be great. thanks

@jweisman
Copy link
Contributor Author

Hi @gracekarina - I'm using OpenAPI 3.0. The spec I shared here can reproduce the issue. Does it not reproduce for you? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants