Skip to content

Conversation

AllyW
Copy link
Contributor

@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
@AllyW AllyW deleted the add-literal-support branch February 28, 2025 06:17
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