Azure / autorest.java

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

tsp, update logic on encode and nullable #2686

Closed weidongxu-microsoft closed 2 months ago

weidongxu-microsoft commented 2 months ago

Issue from openai-assistants on stream-style-serialization https://github.com/Azure/azure-sdk-for-java/issues/38725


code on @encode https://github.com/Azure/autorest.java/pull/2686/commits/4bc5ea4047139e16e8fa4e8347e8eac66cd6afb8

change on test code https://github.com/Azure/autorest.java/pull/2686/commits/c903675ade8a679995b7f87c17d033284ecfb755 I've checked with Chenjie that TCGC should already handle it like this.


code on nullable required https://github.com/Azure/autorest.java/pull/2686/commits/b6b94e4976d58ca09023630d853780470a1a6947

change on test code https://github.com/Azure/autorest.java/pull/2686/commits/4fae1451e3f78489de7a6715185846b95d093ddc

weidongxu-microsoft commented 2 months ago

about required nullable

playground for tsp to swagger https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvcmVzdCI7Cgp1c2luZyBUeXBlU3BlYy5IdHRwOwoKQHNlcnZpY2UoewogIHRpdGxlOiAiT3B0aW9uYWwiLAp9KQpuYW1lc3BhY2UgQ2FkbC7IHTsKCm1vZGVsIMgRIMRDYm9vbGVhbj86yAogPSB0cnVlO8ocTnVsbGFibGXLJHwgbnVsbMskUmVxdWlyZWTJI9McyEjUR3N0cmluZz86xwnKE8t9xhHRNcp70DzSedFDYnl0ZXPkANnECMQRaW50PzrEBjMyxA9sb%2BUAlmludDY0xBBmbG9hxCHFCMYjZG915gCgxRTGJ2R1cmHkAWU%2FOskLxRdhdGVUaW3ELXV0Y0THDuoAsUxpc8Rdxg1bXekAoURpY8QYUmVjb3JkPMUTPsQdQGVuY29kZSjISktub3duRcQUaW5nLnVuaXjEFnN0YW1wLOYAxCkKICBlcG9jaMgz8gEk6wCa6wEp32vfa8UzyGPwAP596AKZSW1tdXTEIuUCmugBxGFkV3JpdOkAqeoB5%2BQAlnZpc2liaWxpdHkoInJlYWQixHbKOk9ubHnoAu%2FrAl19CgpAd2l0aMgbUHJvcGVydGllc%2BcAikFsyxTtAzAuLusDUSAgaegAszrqAL7GYHJvdXRlKCIvb8cuIikKaW50ZXJm5AOZyENPcMVVQHB1dMQHyDRwdXTlAMlwdXQoCiAgICBAaGVhZGVyIHJlcXVlc3RIxQ7wARIs2ivxAQQgPSAidGVzdC3GLiLHPHF1ZXJ5%2BQPU1CX5BB3cUvgECs007wQT0xz4BBzTK%2FcBLNQj9wQuxzJib2R56QG%2FPzrJC8QfKTrlAc7qAYTGB9B85AI40CTzAqXKb8QFPzr2ApXEKH3kAnI%3D&e=%40azure-tools%2Ftypespec-autorest&options=%7B%7D

code-model from above swagger

        - schema: *ref_18
          nullable: true
          required: true
          serializedName: epochDateTimeRequiredNullable
          language:
            default:
              name: epochDateTimeRequiredNullable
              description: ''
          protocol: {}

code-model from tsp directly

        - language:
            default:
              name: epochDateTimeRequiredNullable
              description: ''
          protocol: {}
          schema: *ref_4
          serializedName: epochDateTimeRequiredNullable
          required: true
          nullable: true
          readOnly: false

so code-model part is consistent between tsp and swagger.

haolingdong-msft commented 2 months ago

putting some comments in this commit: https://github.com/Azure/autorest.java/commit/c903675ade8a679995b7f87c17d033284ecfb755