Azure / autorest.java

Extension for AutoRest (https://github.com/Azure/autorest) that generates Java code
MIT License
33 stars 80 forks source link

tsp, correct way to write encode on scalar #2643

Closed weidongxu-microsoft closed 3 months ago

weidongxu-microsoft commented 4 months ago

The @encode should be added on the scalar type, not property of union type | null (it is utcDateTime to be @encode, not the property, nor union)

If written as

  @encode(DateTimeKnownEncoding.unixTimestamp, int64)
  epochDateTimeRequiredNullable: utcDateTime | null;

typespec-autorest would be wrong https://github.com/Azure/azure-rest-api-specs/blob/main/specification/ai/data-plane/OpenAI.Assistants/OpenApiV2/preview/2024-02-15-preview/assistants_generated.json#L3411-L3423

weidongxu-microsoft commented 4 months ago

playground https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvcmVzdCI7Cgp1c2luZyBUeXBlU3BlYy5IdHRwOwoKQHNlcnZpY2UoewogIHRpdGxlOiAiT3B0aW9uYWwiLAp9KQpuYW1lc3BhY2UgQ2FkbC7IHcQ9ZW5jb2RlKERhdGVUaW1lS25vd25FxBRpbmcudW5peMQWc3RhbXAsIGludDY0KQpzY2FsYXIgZXBvY2jIOCBleHRlbmRzIHV0Y8gUOwoKbW9kZWwgyHAg5ACizTdSZXF1aXJlZE51bGxhYuQAus5WfCBudWxsO9A3yC8%2FzzA7Cn0KCkByb3V0ZSgiL2%2FHdyIpCmludGVyZuQBAegAjE9w5QCOQHB1dMQHyDRwdXQiKQogIHB1dCgKICAgIEBib2R5yTY%2FOskLLAogICk6xUUgIEBoZWFkZXIgxgfoANY6IHN0cmluZ%2BQAwNAky1LNJcVvxAU%2FOiB7fcQVfTsKfQ%3D%3D&e=%40azure-tools%2Ftypespec-autorest&options=%7B%7D