Skip to content

[autorest] XML annotation support#3290

Merged
witemple-msft merged 9 commits intoAzure:mainfrom
witemple-msft:witemple-msft/tsp-autorest-xml
Sep 26, 2025
Merged

[autorest] XML annotation support#3290
witemple-msft merged 9 commits intoAzure:mainfrom
witemple-msft:witemple-msft/tsp-autorest-xml

Conversation

@witemple-msft
Copy link
Copy Markdown
Member

@witemple-msft witemple-msft commented Sep 15, 2025

This PR adds support for XML metadata annotations to typespec-autorest:

  • Changes the logic around top-level produces/consumes. It will now allow JSON or XML, rather than always using JSON only. If a service uses both, then it will pick both. It maintains the logic of only emitting operation-level produces/consumes if an operation differs from the top-level.
  • Optionally depends on @typespec/xml. If it is not installed, all XML emit functionality is disabled.
  • Emits xml.name for processed schemas if the XML name differs from the schema name.
  • Emits xml.namespace and xml.prefix as needed.
  • Emits xml.attribute for properties that are marked as attributes.
  • Prefers XML names for properties if the service is only XML.
  • Emits x-ms-text for properties that are @unwrapped if the property's effective encoded type is or extends TypeSpec.string.
  • Emits xml.wrapped: true by default for all properties that have array types, unless the property is marked @unwrapped.
  • Adds several validation tests for XML and hybrid XML/json services.

Closes #1682

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Sep 17, 2025

All changed packages have been documented.

  • @azure-tools/typespec-autorest
Show changes

@azure-tools/typespec-autorest - feature ✏️

Added support for emitting XML annotations.

@witemple-msft witemple-msft changed the title [autorest] WIP XML support [autorest] XML annotation support Sep 17, 2025
@witemple-msft witemple-msft marked this pull request as ready for review September 17, 2025 18:17
@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Sep 17, 2025

You can try these changes here

🛝 Playground 🌐 Website

Comment thread packages/typespec-autorest/test/xml.test.ts Outdated
Comment thread packages/typespec-autorest/test/xml.test.ts
@timotheeguerin timotheeguerin added the int:azure-specs Run integration tests against azure-rest-api-specs label Sep 26, 2025
@witemple-msft witemple-msft added this pull request to the merge queue Sep 26, 2025
Merged via the queue into Azure:main with commit 2ac47f2 Sep 26, 2025
26 checks passed
@witemple-msft witemple-msft deleted the witemple-msft/tsp-autorest-xml branch September 26, 2025 19:06
markcowl pushed a commit to markcowl/typespec-azure that referenced this pull request Sep 26, 2025
This PR adds support for XML metadata annotations to typespec-autorest:

- Changes the logic around top-level produces/consumes. It will now
allow JSON or XML, rather than always using JSON only. If a service uses
both, then it will pick both. It maintains the logic of only emitting
operation-level produces/consumes if an operation differs from the
top-level.
- Optionally depends on `@typespec/xml`. If it is not installed, all XML
emit functionality is disabled.
- Emits `xml.name` for processed schemas if the XML name differs from
the schema name.
- Emits `xml.namespace` and `xml.prefix` as needed.
- Emits `xml.attribute` for properties that are marked as attributes.
- Prefers XML names for properties if the service is only XML.
- Emits `x-ms-text` for properties that are `@unwrapped` if the
property's effective encoded type is or extends `TypeSpec.string`.
- Emits `xml.wrapped: true` by default for all properties that have
array types, unless the property is marked `@unwrapped`.
- Adds several validation tests for XML and hybrid XML/json services.

Closes Azure#1682
markcowl pushed a commit to markcowl/typespec-azure that referenced this pull request Sep 27, 2025
This PR adds support for XML metadata annotations to typespec-autorest:

- Changes the logic around top-level produces/consumes. It will now
allow JSON or XML, rather than always using JSON only. If a service uses
both, then it will pick both. It maintains the logic of only emitting
operation-level produces/consumes if an operation differs from the
top-level.
- Optionally depends on `@typespec/xml`. If it is not installed, all XML
emit functionality is disabled.
- Emits `xml.name` for processed schemas if the XML name differs from
the schema name.
- Emits `xml.namespace` and `xml.prefix` as needed.
- Emits `xml.attribute` for properties that are marked as attributes.
- Prefers XML names for properties if the service is only XML.
- Emits `x-ms-text` for properties that are `@unwrapped` if the
property's effective encoded type is or extends `TypeSpec.string`.
- Emits `xml.wrapped: true` by default for all properties that have
array types, unless the property is marked `@unwrapped`.
- Adds several validation tests for XML and hybrid XML/json services.

Closes Azure#1682
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

int:azure-specs Run integration tests against azure-rest-api-specs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding xml support for autorest emitter

3 participants