question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Add an swagger extension to support xml tag with attributes and value

See original GitHub issue

Swagger specifications (both 2.0 and 3.0) don’t support xml tags that have both an attribute and a value. For instance, this tag of ServiceBus Namespace API:

<title type="text">the title</title>

There is an open api issue: https://github.com/OAI/OpenAPI-Specification/issues/630.

Is it possible to have an extension in swagger file so autorest can generate the correct model class and msrest can serialize/deserialize?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
daviwilcommented, Jul 15, 2020

This is available in AutoRest Core 3.0.6290, it’s a dev release so you’ll have to reference it directly when running AutoRest (--version:3.0.6290) to try it. I’ll ship a regular update to AutoRest Core once I figure out what broke regression tests recently.

1reaction
daviwilcommented, Jul 17, 2020

@lmazuel spoke about this over Teams, we think a good approach for now is to use an extension to indicate when a property should be treated as the text body of an XML element. Here’s an example:

Swagger input:

        "message": {
          "type": "string",
          "xml": {
            "x-ms-text": true
          }
        }

CodeModel output:

    - !<!StringSchema> &ref_7
      type: string
      apiVersions:
        - !<!ApiVersion> 
          version: '2016-02-29'
      serialization:
        xml:
          attribute: false
          wrapped: false
          extensions:
            x-xml-text: true
      language: !<!Languages> 
        default:
          name: ErrorMessage
          description: ''
      protocol: !<!Protocols> {}

AutoRest passes the x-xml-text extension straight through to the CodeModel (it ends up under the xml.extensions sub-object) so the Python generator should be able to pick that up and use it to map the XML appropriately. Once the OpenAPI folks standardize on an approach we can add official support for it in AutoRest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Representing XML - Swagger
OAS 3 This guide is for OpenAPI 3.0. Representing XML. In your API specification, you can describe data in both XML and JSON...
Read more >
OpenAPI Specification - Version 3.0.3 - Swagger
The OpenAPI Specification defines a standard interface to RESTful APIs which allows both humans and computers to understand service capabilities without ...
Read more >
OpenAPI Extensions - Swagger
Many API-related products that support OpenAPI make use of extensions to document their own attributes, such as Amazon API Gateway, ReDoc, APIMatic and ......
Read more >
Describing Parameters - Swagger
Query parameters can be primitive values, arrays and objects. OpenAPI 3.0 provides several ways to serialize objects and arrays in the query string....
Read more >
Customizing your auto-generated Swagger Definitions in 1.5.x
The @SwaggerDefinition annotation is the single biggest addition to the core annotations; it provides you a means to add definition-level ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found