Skip to content

[codegen-all] XML Object schema not parsed? #5918

@tuxbotix

Description

@tuxbotix
Description

I implemented a couple of schemas based on XML object attributes to wrap these objects, etc.
Unfortunately only swagger-ui and handful of example generators did read and use these values, I failed to see directly working code (with or without xml serializing).

Please correct me and help if my rather exhaustive search and research was incorrect in this conclusion!!

Swagger-codegen version

Current stable and master both have this issue.

Swagger declaration file content or url

I tested multiple definitions which have same or similar xml object declarations. I verified the schema via swagger-editor and it nicely generate the examples for XML and JSON as they should have been.

For the final test, I generated random strings and set as "name" in xml nodes, used a bash script to generate for all languages and finally did a recursive search inside all files for this random string. 😋

"definitions":{
    "someModel":{
        "type":"object",
        "xml":{
            "name":"someName",
            "wrapped":true
        },
        "properties":{
            "propOne":{
                "type":"string"
            },
            "propTwo":{
                "type":"string"
            }
        }
    }
}
Command line used for generation

Tested on all languages via a bash script.
java -jar swagger-codegen-cli.jar spec.json -l -o test_outputs/

Steps to reproduce

From the looks of it, InlineModelResolver.java does not completely read the XML properties and seems to do nothing. On top of that, I failed to see any of the languages (didn't test all library combos) having these xml attributes other than server side swagger JSON or YAML files. Some of documentation and examples were generated, but didn't see any code that would do the job.

Related issues
Suggest a Fix
  1. Figure out or at least point us to some documentation on how to read and expose these properties
  2. Update mustache files accordingly.
  3. How to handle xml names, etc may depend on language, serializer, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions