Extension for AutoRest (https://github.com/Azure/autorest) that generates TypeScript code. The transpiled javascript code is isomorphic. It can be run in browser and in node.js environment.
MIT License
177
stars
75
forks
source link
Generator defaults to an empty array for optional array properties #2108
When functions is not specified in the input, the property should not be present in the request.
Actual behavior
functions has value [] in the request. While this makes sense for required array properties, it does not make sense in this scenario, and causes issues, since [] does not satisfy the @minItems(1) constraint. OpenAI returns an error when passing [] here.
Encountered when generating the unbranded OpenAI client:
Context
CreateChatCompletionRequest
has the following array property declared in TypeSpec with@minItems(1)
:https://github.com/Azure/autorest.typescript/blob/8fdc016a9080e6ac9decfb85319503791390c6ab/packages/typespec-test/test/openai_generic/spec/completions/models.tsp#L159-L162
Expected behavior
When
functions
is not specified in the input, the property should not be present in the request.Actual behavior
functions
has value[]
in the request. While this makes sense for required array properties, it does not make sense in this scenario, and causes issues, since[]
does not satisfy the@minItems(1)
constraint. OpenAI returns an error when passing[]
here.