Open swathipil opened 4 months ago
@swathipil
This appears to be bug from typespec-autorest, which is used to convert the TypeSpec to Swagger.
"x-ms-pageable": {
"nextLinkName": "NextLink"
}
It should include the itemName: Value
as well
see https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-pageable on itemName
You can move this issue to https://github.com/Azure/typespec-azure/issues, which contains typespec-autorest lib
Here is one of your Swagger, prior typespec https://github.com/Azure/azure-rest-api-specs/blob/616302e10e5ce0f80d2f0eaf8002f3e39d033696/specification/schemaregistry/data-plane/Microsoft.EventHub/stable/2023-07-01/schemaregistry.json#L49-L52
You can see
"x-ms-pageable": {
"nextLinkName": "nextLink",
"itemName": "schemaGroups"
},
"SchemaGroups": {
"type": "object",
"description": "Object received from the registry containing the list of schema groups and link to next batch page.",
"properties": {
"schemaGroups": {
"type": "array",
"description": "Array of schema groups.",
"items": {
"$ref": "#/definitions/SchemaGroup"
},
"x-ms-client-name": "groups"
},
"nextLink": {
"type": "string",
"description": "URl to next batch of schema groups"
}
}
},
The value of itemName
matchs the schemaGroups
property in SchemaGroups
.
BTW, I am not sure why schemaGroups
changed to Value
, nextLink
changed to NextLink
in same api-version?
Hi @weidongxu-microsoft - That was a bug in the swagger before, but the list operations are not part of the public API for the SDKs so we never tested them. I recently converted the swagger to typespec and tested these operations as well, and found that the service was returning Value/NextLink rather than schemaGroups/nextLink. "Value"/"NextLink" are correct.
Got it.
Then the question is still on typespec-autorest about its missing
"itemName": "Value"
when convert TypeSpec to Swagger.
Please raise it on their repo https://github.com/Azure/typespec-azure/issues
Meanwhile, you may have to use a directive in readme.md to add that "itemName": "Value"
into the autorest procedure, to avoid failure.
@weidongxu-microsoft - This error doesn't happen during the conversion, and we're able to successfully generate from the tsp, which also has "Value" rather than "value". This error happens when we run autorest.java with the swagger, not the typespec. So I believe this is a problem with generating from swagger, and not the typespec to swagger converter.
When trying to generate Java code using the swagger emitted from [this tsp], we run into the following error:
This is because autorest for Java seems to expect that the property be called "value" rather than "Value" in the SchemaGroups/SchemaVersions definitions. However, the Schema Registry service returns "Value". For example:
This seems to be a bug in autorest.java, as it works with Python and the swagger matches service behavior.