swagger-api / swagger-api/swagger-codegen

[codegen-all] XML Object schema not parsed?

Open
#5,918 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with InlineModelResolver.java and the language-specific mustache files; reproduce the report with the supplied schema and swagger-codegen-cli.jar command across a language. Compare generated output with the XML values shown by swagger-ui and the example generators. Done means the XML properties are either exposed in affected generated outputs or their supported limitations are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, java
Domain
api, tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.