Commit bbf7efe
feat(openapi3): add @pageSize decorator support for x-ms-list-page-size extension (#9618)
OpenAPI parameters with `x-ms-list-page-size: true` were not being
converted to TypeSpec's `@pageSize` decorator during import.
## Changes
- **Modified `getParameterDecorators()`** in `decorators.ts` to detect
`x-ms-list-page-size` extension and emit `@pageSize` decorator when
`true`
- **Added tests** covering true/false/absent cases and full document
rendering
## Example
OpenAPI parameter:
```yaml
parameters:
- name: page_size
in: query
schema:
type: integer
format: int32
x-ms-list-page-size: true
```
Now converts to:
```typescript
@extension("x-ms-list-page-size", true)
@pageSize
@query
page_size: int32
```
Note: The `@extension` decorator was already being emitted; this adds
the semantic `@pageSize` decorator alongside it.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
----
*This section details on the original issue you should resolve*
<issue_title>Add support for importing the pageSize decorator based on
the relevant OpenAPI extension</issue_title>
<issue_description>### Clear and concise description of the problem
Related microsoft/openai-openapi-pr#568
Based on the following OpenAPI description, we should get the following
TypeSpec definition imported
```yaml
openapi: 3.0.0
info:
title: Widget Service
version: 0.0.0
tags:
- name: Widgets
paths:
/widgets:
get:
operationId: Widgets_list
description: List widgets
parameters:
- name: page_size
in: query
required: true
schema:
type: integer
format: int32
#this is the extension that matters
x-ms-list-page-size: true
explode: false
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Widget'
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- Widgets
post:
operationId: Widgets_create
description: Create a widget
parameters: []
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- Widgets
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
/widgets/{id}:
get:
operationId: Widgets_read
description: Read widgets
parameters:
- name: id
in: path
required: true
schema:
type: string
readOnly: true
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- Widgets
patch:
operationId: Widgets_update
description: Update a widget
parameters:
- name: id
in: path
required: true
schema:
type: string
readOnly: true
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- Widgets
requestBody:
required: true
content:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/WidgetMergePatchUpdate'
delete:
operationId: Widgets_delete
description: Delete a widget
parameters:
- name: id
in: path
required: true
schema:
type: string
readOnly: true
responses:
'204':
description: 'There is no content to send for this request, but the headers may be useful. '
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- Widgets
/widgets/{id}/analyze:
post:
operationId: Widgets_analyze
description: Analyze a widget
parameters:
- name: id
in: path
required: true
schema:
type: string
readOnly: true
responses:
'200':
description: The request has succeeded.
content:
text/plain:
schema:
type: string
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- Widgets
components:
schemas:
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
...
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #9616
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: Vincent Biret <vibiret@microsoft.com>1 parent 5e73d5b commit bbf7efe
File tree
3 files changed
+166
-0
lines changed- .chronus/changes
- packages/openapi3
- src/cli/actions/convert/utils
- test/tsp-openapi3
3 files changed
+166
-0
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
0 commit comments