Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to literal type #447

Merged
merged 2 commits into from
Feb 6, 2025
Merged

Conversation

AllyW
Copy link
Member

@AllyW AllyW commented Jan 27, 2025

Refer to autorest literal type parsing: https://github.com/Azure/typespec-azure/blob/main/packages/typespec-autorest/src/openapi.ts#L2358-L2373
test property:

  @doc("The datasource type")
  dataSourceType: "AzureVM";

  @doc("The datasource Int")
  dataSourceInt: 12;

  @doc("The datasource Float")
  dataSourceFloat: 12.5;

to:

"props": [
                            {
                              "type": "string",
                              "enum": {
                                "items": [
                                  {
                                    "value": "AzureVM"
                                  }
                                ]
                              },
                              "name": "dataSourceType",
                              "description": "The datasource type",
                              "required": true
                            },
                            {
                              "type": "integer",
                              "enum": {
                                "items": [
                                  {
                                    "value": 12
                                  }
                                ]
                              },
                              "name": "dataSourceInt",
                              "description": "The datasource Int",
                              "required": true
                            },
                            {
                              "type": "float",
                              "enum": {
                                "items": [
                                  {
                                    "value": 12.5
                                  }
                                ]
                              },
                              "name": "dataSourceFloat",
                              "description": "The datasource Float",
                              "required": true
                            }
]

@AllyW AllyW force-pushed the add-literal-support branch from 010f025 to f2974bd Compare February 6, 2025 03:33
@kairu-ms kairu-ms merged commit 5193a31 into Azure:dev Feb 6, 2025
3 checks passed
@kairu-ms kairu-ms mentioned this pull request Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants