OpenAPITools / OpenAPITools/openapi-generator

XML 'wrapped' lost on internal conversion from openapi v2 to v3

Open
#1,581 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

I am currently unable to generate wrapped XML lists using openapi v2. This works fine when I try the same thing with a spec written in openapi v3.

As far as I can tell, this is because openapi-generator drops xml: wrapped: true during the conversion from openapi v2 to v3.

openapi-generator version

Current master

OpenAPI declaration file content or url
Openapi v2 definition that works:
  XmlList:
    description: An XML list with items directly defined
    type: array
    xml:
      wrapped: true
    items:
      type: string
      xml:
        name: xml_list_inner

Is converted to:

      "XmlList" : {
        "type" : "array",
        "description" : "An XML list with items directly defined",
        "items" : {
          "type" : "string",
          "xml" : {
            "name" : "xml_list_inner"
          }
        }
Openapi v2 definition that doesn't:
  XmlListRef:
    description: An XML list with items referenced. The wrapping doesn't currently work - it's stripped during the conversion to openapi v3.
    type: array
    xml:
      wrapped: true
    items:
      $ref: '#/definitions/XmlInner'
  XmlListRefInner:
    type: string
    xml:
      name: xml_list_ref_inner

is converted to:

      "XmlListRef" : {
        "type" : "array",
        "description" : "An XML list with items referenced. The wrapping doesn't currently work - it's stripped during the conversion to openapi v3.",
        "items" : {
          "$ref" : "#/components/schemas/XmlInner"
        }
...
      "XmlListRefInner" : {
        "type" : "string",
        "xml" : {
          "name" : "xml_list_ref_inner"
        }
      },
Openapi v3 definition that works:
components:
  schemas:
    XmlArray:
      type: array
      xml:
        wrapped: true
      items:
        $ref: '#/components/schemas/XmlInner'
    XmlInner:
      type: string
      xml:
        name: another
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

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

Reproduce the conversion using the supplied OpenAPI v2 definitions and compare the resulting v3 schemas, focusing on arrays whose items use $ref. Trace the v2-to-v3 conversion entry point for XML metadata and add a regression test; done means wrapped: true is retained for referenced-item arrays.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.