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 Generation does not calculate root tag name correctly #1982

Closed
JessieAMorris opened this issue Feb 22, 2016 · 6 comments
Closed

XML Generation does not calculate root tag name correctly #1982

JessieAMorris opened this issue Feb 22, 2016 · 6 comments
Assignees
Milestone

Comments

@JessieAMorris
Copy link

If I create a response schema to be used for XML then Swagger UI shows an error that:

<?xml version="1.0"?>
<!-- invalid XML: Node name is not provided -->

This is despite having my schema named.

For example, the following schema does not work:

    authentication:
        type: object
        properties:
            response_code:
                type: integer
            message:
                type: string
            token:
                type: string

but if I add the xml name to it it works correctly:

    authentication:
        type: object
        properties:
            response_code:
                type: integer
            message:
                type: string
            token:
                type: string
      xml:
         name: authentication
@webron
Copy link
Contributor

webron commented Feb 22, 2016

@bodnia can you please look at that?

@bodnia
Copy link
Contributor

bodnia commented Feb 23, 2016

@JessieAMorris I tried schema you provided, please see the results I got:
When placing this into definitions:

definitions:
  authentication:
    type: object
    properties:
      response_code:
        type: integer
      message:
        type: string
      token:
        type: string

and then referring to it in schema:

schema:
  $ref: "#/definitions/authentication"

then the result is
XML example

As per specification on top level in schema object there are following properties supported:

$ref - As a JSON Reference
format (See Data Type Formats for further details)
title
description (GFM syntax can be used for rich text representation)
default (Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object)
multipleOf
maximum
exclusiveMaximum
minimum
exclusiveMinimum
maxLength
minLength
pattern
maxItems
minItems
uniqueItems
maxProperties
minProperties
required
enum
type

So the correctly schema would appear in case of adding

xml : 
  name: 'your_custom_name'

to define a root node name of xml example.
Also there is an example of simple model in specification.

@webron Does this make sense?

@webron
Copy link
Contributor

webron commented Feb 23, 2016

@bodnia it does, but I seem to be getting something else when trying:

paths:
    # This is a path endpoint. Change it.
    /authenticate:
        # This is a HTTP operation
        post:
            # Describe this verb here. Note: you can use markdown
            description: |
                Authenticates a user. Returns a `Authentication` object.
            consumes:
                - application/x-www-form-encoded
            produces:
                - application/xml
            parameters:
                # An example parameter that is in query and is required
                -
                    name: username
                    in: formData
                    description: User's username
                    required: true
                    type: string
                    format: string
                -
                    name: password
                    in: formData
                    description: User's password
                    required: true
                    type: string
                    format: string
                -
                    name: app_id
                    in: formData
                    description: |
                        Identification string used to uniquely identify application, platform, and version of the client making the authentication request. (Example: 1554381236 represents Mvelopes for iPhone version 1.0.0.)
                    required: true
                    type: number
                    format: int
                -
                    name: unique_device_id
                    in: formData
                    description: |
                        The manufacturer-provided unique ID assigned to this device. (UDID for Apple devices.)
                    required: true
                    type: string
                    format: string
            # Expected responses for this operation:
            responses:
                # Response code
                200:
                    description: Successful response
                        # A schema describing your response object.
                        # Use JSON Schema format
                    schema:
                        $ref: '#/definitions/Authentication'

definitions:
    Authentication:
        type: object
        properties:
            response_code:
                type: integer
            message:
                type: string
            token:
                type: string

Can you try that?

@bodnia
Copy link
Contributor

bodnia commented Feb 23, 2016

@webron I see the issue, the same in "other" responses comes. It used to be fixed but looks like it was lost during some merge. I'll fix this

@webron
Copy link
Contributor

webron commented Feb 23, 2016

Thanks!

@fehguy fehguy closed this as completed in 3373944 Mar 1, 2016
fehguy added a commit that referenced this issue Mar 1, 2016
Jonahss pushed a commit to eaze/swagger-ui that referenced this issue Aug 12, 2016
vincent-zurczak pushed a commit to roboconf/swagger-ui that referenced this issue Aug 19, 2016
vincent-zurczak pushed a commit to roboconf/swagger-ui that referenced this issue Aug 19, 2016
@fehguy fehguy added this to the v2.2.1 milestone Aug 23, 2016
@Rilussion
Copy link

Is this broken again ?? I am having the same issue mentioned originally where xml generation fails if xml node name is not specified.

Please advise.

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

5 participants