Forum Discussion

DavidThielen's avatar
DavidThielen
Occasional Contributor
5 years ago

How do I report a bug?

I think I've found a bug.

In our Swagger Hub listing for our API, for “POST /v2/document”, for Properties, Parameters, Datasources, and DataSets (inside Datasources) it’s not doing the Property, … inside it for the request body as application/xml.

 

For example it has:

                <Properties>

                                <Name>string</Name>

                                <Value>string</Value>

                </Properties>

 

When it should have:

                <Properties>

                                <Property>

                                                <Name>string</Name>

                                                <Value>string</Value>

                                </Property>

                </Properties>

 

For application/json it appears to be correct (an array):

  "Properties": [

    {

      "Name": "string",

      "Value": "string"

    }

  ],

 

Is this a bug in my yaml or a bug in SwaggerHub?

 

Thanks - dave

 

 

  • Hi Dave,

     

    You need to add a couple of XML-specific attributes to the schemas:

     

    1) In Template.Properties, add xml.wrapped=true:

     

        Template:
          type: object
          properties:
            ...
            Properties:
              description: "Windward properties for this document. These override any properties set in the configuration file on the server side."
              type: array
              items:
                $ref: '#/components/schemas/Property'
              xml:
                wrapped: true
            ...

     

     

    2) In the Property schema, add xml.name:

     

        Property:
          type: object
          description: "A property set at the individual document generation level."
          properties:
            ...
          xml:
            name: Property

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Dave,

     

    You need to add a couple of XML-specific attributes to the schemas:

     

    1) In Template.Properties, add xml.wrapped=true:

     

        Template:
          type: object
          properties:
            ...
            Properties:
              description: "Windward properties for this document. These override any properties set in the configuration file on the server side."
              type: array
              items:
                $ref: '#/components/schemas/Property'
              xml:
                wrapped: true
            ...

     

     

    2) In the Property schema, add xml.name:

     

        Property:
          type: object
          description: "A property set at the individual document generation level."
          properties:
            ...
          xml:
            name: Property

     

    • DavidThielen's avatar
      DavidThielen
      Occasional Contributor

      That solved it.

      Out of curiosity, why is this needed? I would think it would happen automatically.

      thanks - dave

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Arrays are not wrapped by default, and XML element names are not inferred for singular/plural forms. This information needs to be added by using the xml keyword.

         

        For more information, please see: