From a68a6bf04ba0079a194a8306e4288cf2503ded1c Mon Sep 17 00:00:00 2001 From: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:21:33 +0800 Subject: [PATCH] fix-body-parameter-required (#2731) * fix-body-parameter-required * fix ci * update * update test case * fix ci * refine the body required logic * bug fix * fix smoke test * fix ci * update test case * update test case * resolve comments --------- Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com> --- .../typespec-ts/review/ai-face-rest.api.md | 168 +++++++++--------- .../typespec-ts/src/clientDefinitions.ts | 82 ++++----- .../generated/typespec-ts/src/parameters.ts | 86 ++++----- .../health-insights-radiologyinsights.api.md | 4 +- .../typespec-ts/src/clientDefinitions.ts | 2 +- .../generated/typespec-ts/src/parameters.ts | 2 +- .../health-insights-clinicalmatching.api.md | 4 +- .../typespec-ts/src/clientDefinitions.ts | 2 +- .../generated/typespec-ts/src/parameters.ts | 2 +- .../typespec-ts/review/openai.api.md | 20 +-- .../typespec-ts/src/clientDefinitions.ts | 10 +- .../generated/typespec-ts/src/parameters.ts | 10 +- .../review/todo-non-branded.api.md | 22 +-- .../typespec-ts/src/clientDefinitions.ts | 6 +- .../generated/typespec-ts/src/parameters.ts | 16 +- .../src/transform/transformParameters.ts | 37 ++-- .../src/transform/transformPaths.ts | 31 ++-- packages/typespec-ts/src/utils/modelUtils.ts | 70 ++++---- .../test/integration/clientStructure.spec.ts | 12 +- .../generated/overload/src/index.d.ts | 2 +- .../generated/parameters/basic/src/index.d.ts | 4 +- .../body-optionality/src/index.d.ts | 4 +- .../parameters/spread/src/index.d.ts | 18 +- .../payload/multipart/src/index.d.ts | 2 +- .../generated/shared-route/src/index.d.ts | 8 +- .../generated/type/union/src/index.d.ts | 40 ++--- .../test/unit/spreadAndAlias.spec.ts | 8 +- 27 files changed, 342 insertions(+), 330 deletions(-) diff --git a/packages/typespec-test/test/faceai/generated/typespec-ts/review/ai-face-rest.api.md b/packages/typespec-test/test/faceai/generated/typespec-ts/review/ai-face-rest.api.md index 954ea5ef50..12eaf35c8f 100644 --- a/packages/typespec-test/test/faceai/generated/typespec-ts/review/ai-face-rest.api.md +++ b/packages/typespec-test/test/faceai/generated/typespec-ts/review/ai-face-rest.api.md @@ -56,7 +56,7 @@ export interface AddFaceListFaceDefaultResponse extends HttpResponse { // @public (undocumented) export interface AddFaceListFaceFromUrl { - post(options?: AddFaceListFaceFromUrlParameters): StreamableMethod; + post(options: AddFaceListFaceFromUrlParameters): StreamableMethod; post(options: AddFaceListFaceParameters): StreamableMethod; } @@ -71,7 +71,7 @@ export interface AddFaceListFaceFromUrl200Response extends HttpResponse { // @public (undocumented) export interface AddFaceListFaceFromUrlBodyParam { // (undocumented) - body?: { + body: { url: string; }; } @@ -164,7 +164,7 @@ export interface AddLargeFaceListFaceDefaultResponse extends HttpResponse { // @public (undocumented) export interface AddLargeFaceListFaceFromUrl { get(options?: GetLargeFaceListFacesParameters): StreamableMethod; - post(options?: AddLargeFaceListFaceFromUrlParameters): StreamableMethod; + post(options: AddLargeFaceListFaceFromUrlParameters): StreamableMethod; post(options: AddLargeFaceListFaceParameters): StreamableMethod; } @@ -179,7 +179,7 @@ export interface AddLargeFaceListFaceFromUrl200Response extends HttpResponse { // @public (undocumented) export interface AddLargeFaceListFaceFromUrlBodyParam { // (undocumented) - body?: { + body: { url: string; }; } @@ -266,7 +266,7 @@ export interface AddLargePersonGroupPersonFaceDefaultResponse extends HttpRespon // @public (undocumented) export interface AddLargePersonGroupPersonFaceFromUrl { - post(options?: AddLargePersonGroupPersonFaceFromUrlParameters): StreamableMethod; + post(options: AddLargePersonGroupPersonFaceFromUrlParameters): StreamableMethod; post(options: AddLargePersonGroupPersonFaceParameters): StreamableMethod; } @@ -281,7 +281,7 @@ export interface AddLargePersonGroupPersonFaceFromUrl200Response extends HttpRes // @public (undocumented) export interface AddLargePersonGroupPersonFaceFromUrlBodyParam { // (undocumented) - body?: { + body: { url: string; }; } @@ -342,7 +342,7 @@ export interface AddLargePersonGroupPersonFaceQueryParamProperties { export interface AddPersonFace { get(options?: GetPersonFacesParameters): StreamableMethod; post(options: AddPersonFaceParameters): StreamableMethod; - post(options?: AddPersonFaceFromUrlParameters): StreamableMethod; + post(options: AddPersonFaceFromUrlParameters): StreamableMethod; } // @public (undocumented) @@ -404,7 +404,7 @@ export interface AddPersonFaceFromUrl202Response extends HttpResponse { // @public (undocumented) export interface AddPersonFaceFromUrlBodyParam { // (undocumented) - body?: { + body: { url: string; }; } @@ -507,7 +507,7 @@ export interface AddPersonGroupPersonFaceDefaultResponse extends HttpResponse { // @public (undocumented) export interface AddPersonGroupPersonFaceFromUrl { - post(options?: AddPersonGroupPersonFaceFromUrlParameters): StreamableMethod; + post(options: AddPersonGroupPersonFaceFromUrlParameters): StreamableMethod; post(options: AddPersonGroupPersonFaceParameters): StreamableMethod; } @@ -522,7 +522,7 @@ export interface AddPersonGroupPersonFaceFromUrl200Response extends HttpResponse // @public (undocumented) export interface AddPersonGroupPersonFaceFromUrlBodyParam { // (undocumented) - body?: { + body: { url: string; }; } @@ -601,7 +601,7 @@ export interface CreateDynamicPersonGroup200Response extends HttpResponse { // @public (undocumented) export interface CreateDynamicPersonGroupBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; }; @@ -629,10 +629,10 @@ export type CreateDynamicPersonGroupParameters = CreateDynamicPersonGroupBodyPar export interface CreateDynamicPersonGroupWithPerson { delete(options?: DeleteDynamicPersonGroupParameters): StreamableMethod; get(options?: GetDynamicPersonGroupParameters): StreamableMethod; - patch(options?: UpdateDynamicPersonGroupWithPersonChangesParameters): StreamableMethod; - patch(options?: UpdateDynamicPersonGroupParameters): StreamableMethod; - put(options?: CreateDynamicPersonGroupWithPersonParameters): StreamableMethod; - put(options?: CreateDynamicPersonGroupParameters): StreamableMethod; + patch(options: UpdateDynamicPersonGroupWithPersonChangesParameters): StreamableMethod; + patch(options: UpdateDynamicPersonGroupParameters): StreamableMethod; + put(options: CreateDynamicPersonGroupWithPersonParameters): StreamableMethod; + put(options: CreateDynamicPersonGroupParameters): StreamableMethod; } // @public (undocumented) @@ -652,7 +652,7 @@ export interface CreateDynamicPersonGroupWithPerson202Response extends HttpRespo // @public (undocumented) export interface CreateDynamicPersonGroupWithPersonBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; addPersonIds: string[]; @@ -687,8 +687,8 @@ export type CreateDynamicPersonGroupWithPersonParameters = CreateDynamicPersonGr export interface CreateFaceList { delete(options?: DeleteFaceListParameters): StreamableMethod; get(options?: GetFaceListParameters): StreamableMethod; - patch(options?: UpdateFaceListParameters): StreamableMethod; - put(options?: CreateFaceListParameters): StreamableMethod; + patch(options: UpdateFaceListParameters): StreamableMethod; + put(options: CreateFaceListParameters): StreamableMethod; } // @public @@ -700,7 +700,7 @@ export interface CreateFaceList200Response extends HttpResponse { // @public (undocumented) export interface CreateFaceListBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -729,8 +729,8 @@ export type CreateFaceListParameters = CreateFaceListBodyParam & RequestParamete export interface CreateLargeFaceList { delete(options?: DeleteLargeFaceListParameters): StreamableMethod; get(options?: GetLargeFaceListParameters): StreamableMethod; - patch(options?: UpdateLargeFaceListParameters): StreamableMethod; - put(options?: CreateLargeFaceListParameters): StreamableMethod; + patch(options: UpdateLargeFaceListParameters): StreamableMethod; + put(options: CreateLargeFaceListParameters): StreamableMethod; } // @public @@ -742,7 +742,7 @@ export interface CreateLargeFaceList200Response extends HttpResponse { // @public (undocumented) export interface CreateLargeFaceListBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -771,8 +771,8 @@ export type CreateLargeFaceListParameters = CreateLargeFaceListBodyParam & Reque export interface CreateLargePersonGroup { delete(options?: DeleteLargePersonGroupParameters): StreamableMethod; get(options?: GetLargePersonGroupParameters): StreamableMethod; - patch(options?: UpdateLargePersonGroupParameters): StreamableMethod; - put(options?: CreateLargePersonGroupParameters): StreamableMethod; + patch(options: UpdateLargePersonGroupParameters): StreamableMethod; + put(options: CreateLargePersonGroupParameters): StreamableMethod; } // @public @@ -784,7 +784,7 @@ export interface CreateLargePersonGroup200Response extends HttpResponse { // @public (undocumented) export interface CreateLargePersonGroupBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -812,7 +812,7 @@ export type CreateLargePersonGroupParameters = CreateLargePersonGroupBodyParam & // @public (undocumented) export interface CreateLargePersonGroupPerson { get(options?: GetLargePersonGroupPersonsParameters): StreamableMethod; - post(options?: CreateLargePersonGroupPersonParameters): StreamableMethod; + post(options: CreateLargePersonGroupPersonParameters): StreamableMethod; } // @public @@ -826,7 +826,7 @@ export interface CreateLargePersonGroupPerson200Response extends HttpResponse { // @public (undocumented) export interface CreateLargePersonGroupPersonBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; }; @@ -853,7 +853,7 @@ export type CreateLargePersonGroupPersonParameters = CreateLargePersonGroupPerso // @public (undocumented) export interface CreateLivenessSession { get(options?: GetLivenessSessionsParameters): StreamableMethod; - post(options?: CreateLivenessSessionParameters): StreamableMethod; + post(options: CreateLivenessSessionParameters): StreamableMethod; } // @public @@ -867,7 +867,7 @@ export interface CreateLivenessSession200Response extends HttpResponse { // @public (undocumented) export interface CreateLivenessSessionBodyParam { // (undocumented) - body?: LivenessSessionCreationContent; + body: LivenessSessionCreationContent; } // @public (undocumented) @@ -899,7 +899,7 @@ export interface CreateLivenessWithVerifySession200Response extends HttpResponse // @public (undocumented) export interface CreateLivenessWithVerifySessionBodyParam { // (undocumented) - body?: LivenessSessionCreationContent; + body: LivenessSessionCreationContent; } // @public (undocumented) @@ -924,7 +924,7 @@ export type CreateLivenessWithVerifySessionParameters = CreateLivenessWithVerify export interface CreateLivenessWithVerifySessionWithVerifyImage { get(options?: GetLivenessWithVerifySessionsParameters): StreamableMethod; post(options: CreateLivenessWithVerifySessionWithVerifyImageParameters): StreamableMethod; - post(options?: CreateLivenessWithVerifySessionParameters): StreamableMethod; + post(options: CreateLivenessWithVerifySessionParameters): StreamableMethod; } // @public @@ -938,7 +938,7 @@ export interface CreateLivenessWithVerifySessionWithVerifyImage200Response exten // @public (undocumented) export interface CreateLivenessWithVerifySessionWithVerifyImageBodyParam { // (undocumented) - body?: LivenessSessionWithVerifyImageCreationContent; + body: LivenessSessionWithVerifyImageCreationContent; } // @public (undocumented) @@ -967,7 +967,7 @@ export type CreateLivenessWithVerifySessionWithVerifyImageParameters = CreateLiv // @public (undocumented) export interface CreatePerson { get(options?: GetPersonsParameters): StreamableMethod; - post(options?: CreatePersonParameters): StreamableMethod; + post(options: CreatePersonParameters): StreamableMethod; } // @public (undocumented) @@ -991,7 +991,7 @@ export interface CreatePerson202Response extends HttpResponse { // @public (undocumented) export interface CreatePersonBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; }; @@ -1016,8 +1016,8 @@ export interface CreatePersonDefaultResponse extends HttpResponse { export interface CreatePersonGroup { delete(options?: DeletePersonGroupParameters): StreamableMethod; get(options?: GetPersonGroupParameters): StreamableMethod; - patch(options?: UpdatePersonGroupParameters): StreamableMethod; - put(options?: CreatePersonGroupParameters): StreamableMethod; + patch(options: UpdatePersonGroupParameters): StreamableMethod; + put(options: CreatePersonGroupParameters): StreamableMethod; } // @public @@ -1029,7 +1029,7 @@ export interface CreatePersonGroup200Response extends HttpResponse { // @public (undocumented) export interface CreatePersonGroupBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -1057,7 +1057,7 @@ export type CreatePersonGroupParameters = CreatePersonGroupBodyParam & RequestPa // @public (undocumented) export interface CreatePersonGroupPerson { get(options?: GetPersonGroupPersonsParameters): StreamableMethod; - post(options?: CreatePersonGroupPersonParameters): StreamableMethod; + post(options: CreatePersonGroupPersonParameters): StreamableMethod; } // @public @@ -1071,7 +1071,7 @@ export interface CreatePersonGroupPerson200Response extends HttpResponse { // @public (undocumented) export interface CreatePersonGroupPersonBodyParam { // (undocumented) - body?: { + body: { name: string; userData?: string; }; @@ -1227,7 +1227,7 @@ export interface DeleteLargeFaceListDefaultResponse extends HttpResponse { export interface DeleteLargeFaceListFace { delete(options?: DeleteLargeFaceListFaceParameters): StreamableMethod; get(options?: GetLargeFaceListFaceParameters): StreamableMethod; - patch(options?: UpdateLargeFaceListFaceParameters): StreamableMethod; + patch(options: UpdateLargeFaceListFaceParameters): StreamableMethod; } // @public @@ -1285,7 +1285,7 @@ export type DeleteLargePersonGroupParameters = RequestParameters; export interface DeleteLargePersonGroupPerson { delete(options?: DeleteLargePersonGroupPersonParameters): StreamableMethod; get(options?: GetLargePersonGroupPersonParameters): StreamableMethod; - patch(options?: UpdateLargePersonGroupPersonParameters): StreamableMethod; + patch(options: UpdateLargePersonGroupPersonParameters): StreamableMethod; } // @public @@ -1313,7 +1313,7 @@ export interface DeleteLargePersonGroupPersonDefaultResponse extends HttpRespons export interface DeleteLargePersonGroupPersonFace { delete(options?: DeleteLargePersonGroupPersonFaceParameters): StreamableMethod; get(options?: GetLargePersonGroupPersonFaceParameters): StreamableMethod; - patch(options?: UpdateLargePersonGroupPersonFaceParameters): StreamableMethod; + patch(options: UpdateLargePersonGroupPersonFaceParameters): StreamableMethod; } // @public @@ -1407,7 +1407,7 @@ export type DeleteLivenessWithVerifySessionParameters = RequestParameters; export interface DeletePerson { delete(options?: DeletePersonParameters): StreamableMethod; get(options?: GetPersonParameters): StreamableMethod; - patch(options?: UpdatePersonParameters): StreamableMethod; + patch(options: UpdatePersonParameters): StreamableMethod; } // @public (undocumented) @@ -1443,7 +1443,7 @@ export interface DeletePersonDefaultResponse extends HttpResponse { export interface DeletePersonFace { delete(options?: DeletePersonFaceParameters): StreamableMethod; get(options?: GetPersonFaceParameters): StreamableMethod; - patch(options?: UpdatePersonFaceParameters): StreamableMethod; + patch(options: UpdatePersonFaceParameters): StreamableMethod; } // @public (undocumented) @@ -1512,7 +1512,7 @@ export type DeletePersonGroupParameters = RequestParameters; export interface DeletePersonGroupPerson { delete(options?: DeletePersonGroupPersonParameters): StreamableMethod; get(options?: GetPersonGroupPersonParameters): StreamableMethod; - patch(options?: UpdatePersonGroupPersonParameters): StreamableMethod; + patch(options: UpdatePersonGroupPersonParameters): StreamableMethod; } // @public @@ -1540,7 +1540,7 @@ export interface DeletePersonGroupPersonDefaultResponse extends HttpResponse { export interface DeletePersonGroupPersonFace { delete(options?: DeletePersonGroupPersonFaceParameters): StreamableMethod; get(options?: GetPersonGroupPersonFaceParameters): StreamableMethod; - patch(options?: UpdatePersonGroupPersonFaceParameters): StreamableMethod; + patch(options: UpdatePersonGroupPersonFaceParameters): StreamableMethod; } // @public @@ -1624,7 +1624,7 @@ export interface DetectFromUrl200Response extends HttpResponse { // @public (undocumented) export interface DetectFromUrlBodyParam { // (undocumented) - body?: { + body: { url: string; }; } @@ -1837,9 +1837,9 @@ export interface FacialHairOutput { // @public (undocumented) export interface FindSimilar { - post(options?: FindSimilarParameters): StreamableMethod; - post(options?: FindSimilarFromFaceListParameters): StreamableMethod; - post(options?: FindSimilarFromLargeFaceListParameters): StreamableMethod; + post(options: FindSimilarParameters): StreamableMethod; + post(options: FindSimilarFromFaceListParameters): StreamableMethod; + post(options: FindSimilarFromLargeFaceListParameters): StreamableMethod; } // @public @@ -1853,7 +1853,7 @@ export interface FindSimilar200Response extends HttpResponse { // @public (undocumented) export interface FindSimilarBodyParam { // (undocumented) - body?: { + body: { faceId: string; maxNumOfCandidatesReturned?: number; mode?: FindSimilarMatchMode; @@ -1887,7 +1887,7 @@ export interface FindSimilarFromFaceList200Response extends HttpResponse { // @public (undocumented) export interface FindSimilarFromFaceListBodyParam { // (undocumented) - body?: { + body: { faceId: string; maxNumOfCandidatesReturned?: number; mode?: FindSimilarMatchMode; @@ -1924,7 +1924,7 @@ export interface FindSimilarFromLargeFaceList200Response extends HttpResponse { // @public (undocumented) export interface FindSimilarFromLargeFaceListBodyParam { // (undocumented) - body?: { + body: { faceId: string; maxNumOfCandidatesReturned?: number; mode?: FindSimilarMatchMode; @@ -3173,7 +3173,7 @@ export type GlassesTypeOutput = string; // @public (undocumented) export interface Group { - post(options?: GroupParameters): StreamableMethod; + post(options: GroupParameters): StreamableMethod; } // @public @@ -3187,7 +3187,7 @@ export interface Group200Response extends HttpResponse { // @public (undocumented) export interface GroupBodyParam { // (undocumented) - body?: { + body: { faceIds: string[]; }; } @@ -3262,7 +3262,7 @@ export interface IdentifyFromDynamicPersonGroup200Response extends HttpResponse // @public (undocumented) export interface IdentifyFromDynamicPersonGroupBodyParam { // (undocumented) - body?: { + body: { faceIds: string[]; dynamicPersonGroupId: string; maxNumOfCandidatesReturned?: number; @@ -3299,7 +3299,7 @@ export interface IdentifyFromLargePersonGroup200Response extends HttpResponse { // @public (undocumented) export interface IdentifyFromLargePersonGroupBodyParam { // (undocumented) - body?: { + body: { faceIds: string[]; largePersonGroupId: string; maxNumOfCandidatesReturned?: number; @@ -3336,7 +3336,7 @@ export interface IdentifyFromPersonDirectory200Response extends HttpResponse { // @public (undocumented) export interface IdentifyFromPersonDirectoryBodyParam { // (undocumented) - body?: { + body: { faceIds: string[]; personIds: string[]; maxNumOfCandidatesReturned?: number; @@ -3364,10 +3364,10 @@ export type IdentifyFromPersonDirectoryParameters = IdentifyFromPersonDirectoryB // @public (undocumented) export interface IdentifyFromPersonGroup { - post(options?: IdentifyFromPersonGroupParameters): StreamableMethod; - post(options?: IdentifyFromLargePersonGroupParameters): StreamableMethod; - post(options?: IdentifyFromPersonDirectoryParameters): StreamableMethod; - post(options?: IdentifyFromDynamicPersonGroupParameters): StreamableMethod; + post(options: IdentifyFromPersonGroupParameters): StreamableMethod; + post(options: IdentifyFromLargePersonGroupParameters): StreamableMethod; + post(options: IdentifyFromPersonDirectoryParameters): StreamableMethod; + post(options: IdentifyFromDynamicPersonGroupParameters): StreamableMethod; } // @public @@ -3381,7 +3381,7 @@ export interface IdentifyFromPersonGroup200Response extends HttpResponse { // @public (undocumented) export interface IdentifyFromPersonGroupBodyParam { // (undocumented) - body?: { + body: { faceIds: string[]; personGroupId: string; maxNumOfCandidatesReturned?: number; @@ -4226,7 +4226,7 @@ export interface UpdateDynamicPersonGroup200Response extends HttpResponse { // @public (undocumented) export interface UpdateDynamicPersonGroupBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4267,7 +4267,7 @@ export interface UpdateDynamicPersonGroupWithPersonChanges202Response extends Ht // @public (undocumented) export interface UpdateDynamicPersonGroupWithPersonChangesBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; addPersonIds?: string[]; @@ -4308,7 +4308,7 @@ export interface UpdateFaceList200Response extends HttpResponse { // @public (undocumented) export interface UpdateFaceListBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4341,7 +4341,7 @@ export interface UpdateLargeFaceList200Response extends HttpResponse { // @public (undocumented) export interface UpdateLargeFaceListBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4371,7 +4371,7 @@ export interface UpdateLargeFaceListFace200Response extends HttpResponse { // @public (undocumented) export interface UpdateLargeFaceListFaceBodyParam { // (undocumented) - body?: { + body: { userData?: string; }; } @@ -4406,7 +4406,7 @@ export interface UpdateLargePersonGroup200Response extends HttpResponse { // @public (undocumented) export interface UpdateLargePersonGroupBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4439,7 +4439,7 @@ export interface UpdateLargePersonGroupPerson200Response extends HttpResponse { // @public (undocumented) export interface UpdateLargePersonGroupPersonBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4469,7 +4469,7 @@ export interface UpdateLargePersonGroupPersonFace200Response extends HttpRespons // @public (undocumented) export interface UpdateLargePersonGroupPersonFaceBodyParam { // (undocumented) - body?: { + body: { userData?: string; }; } @@ -4504,7 +4504,7 @@ export interface UpdatePerson200Response extends HttpResponse { // @public (undocumented) export interface UpdatePersonBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4534,7 +4534,7 @@ export interface UpdatePersonFace200Response extends HttpResponse { // @public (undocumented) export interface UpdatePersonFaceBodyParam { // (undocumented) - body?: { + body: { userData?: string; }; } @@ -4566,7 +4566,7 @@ export interface UpdatePersonGroup200Response extends HttpResponse { // @public (undocumented) export interface UpdatePersonGroupBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4599,7 +4599,7 @@ export interface UpdatePersonGroupPerson200Response extends HttpResponse { // @public (undocumented) export interface UpdatePersonGroupPersonBodyParam { // (undocumented) - body?: { + body: { name?: string; userData?: string; }; @@ -4629,7 +4629,7 @@ export interface UpdatePersonGroupPersonFace200Response extends HttpResponse { // @public (undocumented) export interface UpdatePersonGroupPersonFaceBodyParam { // (undocumented) - body?: { + body: { userData?: string; }; } @@ -4666,10 +4666,10 @@ export interface VerificationResultOutput { // @public (undocumented) export interface VerifyFaceToFace { - post(options?: VerifyFaceToFaceParameters): StreamableMethod; - post(options?: VerifyFromPersonGroupParameters): StreamableMethod; - post(options?: VerifyFromLargePersonGroupParameters): StreamableMethod; - post(options?: VerifyFromPersonDirectoryParameters): StreamableMethod; + post(options: VerifyFaceToFaceParameters): StreamableMethod; + post(options: VerifyFromPersonGroupParameters): StreamableMethod; + post(options: VerifyFromLargePersonGroupParameters): StreamableMethod; + post(options: VerifyFromPersonDirectoryParameters): StreamableMethod; } // @public @@ -4683,7 +4683,7 @@ export interface VerifyFaceToFace200Response extends HttpResponse { // @public (undocumented) export interface VerifyFaceToFaceBodyParam { // (undocumented) - body?: { + body: { faceId1: string; faceId2: string; }; @@ -4718,7 +4718,7 @@ export interface VerifyFromLargePersonGroup200Response extends HttpResponse { // @public (undocumented) export interface VerifyFromLargePersonGroupBodyParam { // (undocumented) - body?: { + body: { faceId: string; largePersonGroupId: string; personId: string; @@ -4754,7 +4754,7 @@ export interface VerifyFromPersonDirectory200Response extends HttpResponse { // @public (undocumented) export interface VerifyFromPersonDirectoryBodyParam { // (undocumented) - body?: { + body: { faceId: string; personId: string; }; @@ -4789,7 +4789,7 @@ export interface VerifyFromPersonGroup200Response extends HttpResponse { // @public (undocumented) export interface VerifyFromPersonGroupBodyParam { // (undocumented) - body?: { + body: { faceId: string; personGroupId: string; personId: string; diff --git a/packages/typespec-test/test/faceai/generated/typespec-ts/src/clientDefinitions.ts b/packages/typespec-test/test/faceai/generated/typespec-ts/src/clientDefinitions.ts index bfd4d3b4c0..8309d06d8d 100644 --- a/packages/typespec-test/test/faceai/generated/typespec-ts/src/clientDefinitions.ts +++ b/packages/typespec-test/test/faceai/generated/typespec-ts/src/clientDefinitions.ts @@ -370,7 +370,7 @@ export interface FindSimilar { * The 'recognitionModel' associated with the query faceId should be the same as the 'recognitionModel' used by the target faceId array. */ post( - options?: FindSimilarParameters, + options: FindSimilarParameters, ): StreamableMethod; /** * Depending on the input the returned similar faces list contains faceIds or persistedFaceIds ranked by similarity. @@ -380,7 +380,7 @@ export interface FindSimilar { * The 'recognitionModel' associated with the query faceId should be the same as the 'recognitionModel' used by the target Face List. */ post( - options?: FindSimilarFromFaceListParameters, + options: FindSimilarFromFaceListParameters, ): StreamableMethod< FindSimilarFromFaceList200Response | FindSimilarFromFaceListDefaultResponse >; @@ -392,7 +392,7 @@ export interface FindSimilar { * The 'recognitionModel' associated with the query faceId should be the same as the 'recognitionModel' used by the target Large Face List. */ post( - options?: FindSimilarFromLargeFaceListParameters, + options: FindSimilarFromLargeFaceListParameters, ): StreamableMethod< | FindSimilarFromLargeFaceList200Response | FindSimilarFromLargeFaceListDefaultResponse @@ -413,7 +413,7 @@ export interface IdentifyFromPersonGroup { * > * The 'recognitionModel' associated with the query faces' faceIds should be the same as the 'recognitionModel' used by the target Person Group. */ post( - options?: IdentifyFromPersonGroupParameters, + options: IdentifyFromPersonGroupParameters, ): StreamableMethod< IdentifyFromPersonGroup200Response | IdentifyFromPersonGroupDefaultResponse >; @@ -430,7 +430,7 @@ export interface IdentifyFromPersonGroup { * > * The 'recognitionModel' associated with the query faces' faceIds should be the same as the 'recognitionModel' used by the target Person Group or Large Person Group. */ post( - options?: IdentifyFromLargePersonGroupParameters, + options: IdentifyFromLargePersonGroupParameters, ): StreamableMethod< | IdentifyFromLargePersonGroup200Response | IdentifyFromLargePersonGroupDefaultResponse @@ -447,7 +447,7 @@ export interface IdentifyFromPersonGroup { * > * The Identify operation can only match faces obtained with the same recognition model, that is associated with the query faces. */ post( - options?: IdentifyFromPersonDirectoryParameters, + options: IdentifyFromPersonDirectoryParameters, ): StreamableMethod< | IdentifyFromPersonDirectory200Response | IdentifyFromPersonDirectoryDefaultResponse @@ -464,7 +464,7 @@ export interface IdentifyFromPersonGroup { * > * The Identify operation can only match faces obtained with the same recognition model, that is associated with the query faces. */ post( - options?: IdentifyFromDynamicPersonGroupParameters, + options: IdentifyFromDynamicPersonGroupParameters, ): StreamableMethod< | IdentifyFromDynamicPersonGroup200Response | IdentifyFromDynamicPersonGroupDefaultResponse @@ -481,7 +481,7 @@ export interface VerifyFaceToFace { * > * The 'recognitionModel' associated with the both faces should be the same. */ post( - options?: VerifyFaceToFaceParameters, + options: VerifyFaceToFaceParameters, ): StreamableMethod< VerifyFaceToFace200Response | VerifyFaceToFaceDefaultResponse >; @@ -494,7 +494,7 @@ export interface VerifyFaceToFace { * > * The 'recognitionModel' associated with the query face should be the same as the 'recognitionModel' used by the Person Group. */ post( - options?: VerifyFromPersonGroupParameters, + options: VerifyFromPersonGroupParameters, ): StreamableMethod< VerifyFromPersonGroup200Response | VerifyFromPersonGroupDefaultResponse >; @@ -507,7 +507,7 @@ export interface VerifyFaceToFace { * > * The 'recognitionModel' associated with the query face should be the same as the 'recognitionModel' used by the Large Person Group. */ post( - options?: VerifyFromLargePersonGroupParameters, + options: VerifyFromLargePersonGroupParameters, ): StreamableMethod< | VerifyFromLargePersonGroup200Response | VerifyFromLargePersonGroupDefaultResponse @@ -521,7 +521,7 @@ export interface VerifyFaceToFace { * > * The Verify operation can only match faces obtained with the same recognition model, that is associated with the query face. */ post( - options?: VerifyFromPersonDirectoryParameters, + options: VerifyFromPersonDirectoryParameters, ): StreamableMethod< | VerifyFromPersonDirectory200Response | VerifyFromPersonDirectoryDefaultResponse @@ -538,7 +538,7 @@ export interface Group { * * The 'recognitionModel' associated with the query faces' faceIds should be the same. */ post( - options?: GroupParameters, + options: GroupParameters, ): StreamableMethod; } @@ -555,7 +555,7 @@ export interface CreateFaceList { * Please consider Large Face List when the face number is large. It can support up to 1,000,000 faces. */ put( - options?: CreateFaceListParameters, + options: CreateFaceListParameters, ): StreamableMethod< CreateFaceList200Response | CreateFaceListDefaultResponse >; @@ -571,7 +571,7 @@ export interface CreateFaceList { ): StreamableMethod; /** Update information of a Face List, including name and userData. */ patch( - options?: UpdateFaceListParameters, + options: UpdateFaceListParameters, ): StreamableMethod< UpdateFaceList200Response | UpdateFaceListDefaultResponse >; @@ -604,7 +604,7 @@ export interface AddFaceListFaceFromUrl { * * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-detection-model */ post( - options?: AddFaceListFaceFromUrlParameters, + options: AddFaceListFaceFromUrlParameters, ): StreamableMethod< AddFaceListFaceFromUrl200Response | AddFaceListFaceFromUrlDefaultResponse >; @@ -653,7 +653,7 @@ export interface CreateLargeFaceList { * > * S0-tier subscription quota: 1,000,000 Large Face Lists. */ put( - options?: CreateLargeFaceListParameters, + options: CreateLargeFaceListParameters, ): StreamableMethod< CreateLargeFaceList200Response | CreateLargeFaceListDefaultResponse >; @@ -671,7 +671,7 @@ export interface CreateLargeFaceList { >; /** Update information of a Large Face List, including name and userData. */ patch( - options?: UpdateLargeFaceListParameters, + options: UpdateLargeFaceListParameters, ): StreamableMethod< UpdateLargeFaceList200Response | UpdateLargeFaceListDefaultResponse >; @@ -750,7 +750,7 @@ export interface AddLargeFaceListFaceFromUrl { * > * S0-tier subscription quota: 1,000,000 faces per Large Face List. */ post( - options?: AddLargeFaceListFaceFromUrlParameters, + options: AddLargeFaceListFaceFromUrlParameters, ): StreamableMethod< | AddLargeFaceListFaceFromUrl200Response | AddLargeFaceListFaceFromUrlDefaultResponse @@ -816,7 +816,7 @@ export interface DeleteLargeFaceListFace { >; /** Update a specified face's userData field in a Large Face List by its persistedFaceId. */ patch( - options?: UpdateLargeFaceListFaceParameters, + options: UpdateLargeFaceListFaceParameters, ): StreamableMethod< UpdateLargeFaceListFace200Response | UpdateLargeFaceListFaceDefaultResponse >; @@ -840,7 +840,7 @@ export interface CreatePersonGroup { * > * to handle larger scale face identification problem, please consider using Large Person Group. */ put( - options?: CreatePersonGroupParameters, + options: CreatePersonGroupParameters, ): StreamableMethod< CreatePersonGroup200Response | CreatePersonGroupDefaultResponse >; @@ -858,7 +858,7 @@ export interface CreatePersonGroup { >; /** Update an existing Person Group's name and userData. The properties keep unchanged if they are not in request body. */ patch( - options?: UpdatePersonGroupParameters, + options: UpdatePersonGroupParameters, ): StreamableMethod< UpdatePersonGroup200Response | UpdatePersonGroupDefaultResponse >; @@ -918,7 +918,7 @@ export interface CreatePersonGroupPerson { * > * 100,000,000 persons in all Person Groups. */ post( - options?: CreatePersonGroupPersonParameters, + options: CreatePersonGroupPersonParameters, ): StreamableMethod< CreatePersonGroupPerson200Response | CreatePersonGroupPersonDefaultResponse >; @@ -958,7 +958,7 @@ export interface DeletePersonGroupPerson { >; /** Update name or userData of a person. */ patch( - options?: UpdatePersonGroupPersonParameters, + options: UpdatePersonGroupPersonParameters, ): StreamableMethod< UpdatePersonGroupPerson200Response | UpdatePersonGroupPersonDefaultResponse >; @@ -980,7 +980,7 @@ export interface AddPersonGroupPersonFaceFromUrl { * * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-detection-model */ post( - options?: AddPersonGroupPersonFaceFromUrlParameters, + options: AddPersonGroupPersonFaceFromUrlParameters, ): StreamableMethod< | AddPersonGroupPersonFaceFromUrl200Response | AddPersonGroupPersonFaceFromUrlDefaultResponse @@ -1024,7 +1024,7 @@ export interface DeletePersonGroupPersonFace { >; /** Update a person persisted face's userData field. */ patch( - options?: UpdatePersonGroupPersonFaceParameters, + options: UpdatePersonGroupPersonFaceParameters, ): StreamableMethod< | UpdatePersonGroupPersonFace200Response | UpdatePersonGroupPersonFaceDefaultResponse @@ -1048,7 +1048,7 @@ export interface CreateLargePersonGroup { * > * S0-tier subscription quota: 1,000,000 Large Person Groups. */ put( - options?: CreateLargePersonGroupParameters, + options: CreateLargePersonGroupParameters, ): StreamableMethod< CreateLargePersonGroup200Response | CreateLargePersonGroupDefaultResponse >; @@ -1066,7 +1066,7 @@ export interface CreateLargePersonGroup { >; /** Update an existing Large Person Group's name and userData. The properties keep unchanged if they are not in request body. */ patch( - options?: UpdateLargePersonGroupParameters, + options: UpdateLargePersonGroupParameters, ): StreamableMethod< UpdateLargePersonGroup200Response | UpdateLargePersonGroupDefaultResponse >; @@ -1126,7 +1126,7 @@ export interface CreateLargePersonGroupPerson { * > * 1,000,000,000 persons in all Large Person Groups. */ post( - options?: CreateLargePersonGroupPersonParameters, + options: CreateLargePersonGroupPersonParameters, ): StreamableMethod< | CreateLargePersonGroupPerson200Response | CreateLargePersonGroupPersonDefaultResponse @@ -1170,7 +1170,7 @@ export interface DeleteLargePersonGroupPerson { >; /** Update name or userData of a person. */ patch( - options?: UpdateLargePersonGroupPersonParameters, + options: UpdateLargePersonGroupPersonParameters, ): StreamableMethod< | UpdateLargePersonGroupPerson200Response | UpdateLargePersonGroupPersonDefaultResponse @@ -1193,7 +1193,7 @@ export interface AddLargePersonGroupPersonFaceFromUrl { * * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-detection-model */ post( - options?: AddLargePersonGroupPersonFaceFromUrlParameters, + options: AddLargePersonGroupPersonFaceFromUrlParameters, ): StreamableMethod< | AddLargePersonGroupPersonFaceFromUrl200Response | AddLargePersonGroupPersonFaceFromUrlDefaultResponse @@ -1237,7 +1237,7 @@ export interface DeleteLargePersonGroupPersonFace { >; /** Update a person persisted face's userData field. */ patch( - options?: UpdateLargePersonGroupPersonFaceParameters, + options: UpdateLargePersonGroupPersonFaceParameters, ): StreamableMethod< | UpdateLargePersonGroupPersonFace200Response | UpdateLargePersonGroupPersonFaceDefaultResponse @@ -1247,7 +1247,7 @@ export interface DeleteLargePersonGroupPersonFace { export interface CreatePerson { /** Creates a new person in a Person Directory. To add face to this person, please call Person Directory "Add Person Face". */ post( - options?: CreatePersonParameters, + options: CreatePersonParameters, ): StreamableMethod; /** * Persons are stored in alphabetical order of personId created in Person Directory "Create Person". @@ -1279,7 +1279,7 @@ export interface DeletePerson { ): StreamableMethod; /** Update name or userData of a person. */ patch( - options?: UpdatePersonParameters, + options: UpdatePersonParameters, ): StreamableMethod; } @@ -1345,7 +1345,7 @@ export interface AddPersonFace { * * This is a long running operation. Use Response Header "Operation-Location" to determine when the AddFace operation has successfully propagated for future requests to "Identify". For further information about Operation-Locations see "Get Face Operation Status". */ post( - options?: AddPersonFaceFromUrlParameters, + options: AddPersonFaceFromUrlParameters, ): StreamableMethod< AddPersonFaceFromUrl202Response | AddPersonFaceFromUrlDefaultResponse >; @@ -1370,7 +1370,7 @@ export interface DeletePersonFace { ): StreamableMethod; /** Update a persisted face's userData field of a person. */ patch( - options?: UpdatePersonFaceParameters, + options: UpdatePersonFaceParameters, ): StreamableMethod< UpdatePersonFace200Response | UpdatePersonFaceDefaultResponse >; @@ -1387,7 +1387,7 @@ export interface CreateDynamicPersonGroupWithPerson { * 'recognitionModel' does not need to be specified with Dynamic Person Groups. Dynamic Person Groups are references to Person Directory "Create Person" and therefore work with most all 'recognitionModels'. The faceId's provided during "Identify" determine the 'recognitionModel' used. */ put( - options?: CreateDynamicPersonGroupWithPersonParameters, + options: CreateDynamicPersonGroupWithPersonParameters, ): StreamableMethod< | CreateDynamicPersonGroupWithPerson202Response | CreateDynamicPersonGroupWithPersonDefaultResponse @@ -1402,7 +1402,7 @@ export interface CreateDynamicPersonGroupWithPerson { * 'recognitionModel' does not need to be specified with Dynamic Person Groups. Dynamic Person Groups are references to Person Directory "Create Person" and therefore work with most all 'recognitionModels'. The faceId's provided during "Identify" determine the 'recognitionModel' used. */ put( - options?: CreateDynamicPersonGroupParameters, + options: CreateDynamicPersonGroupParameters, ): StreamableMethod< | CreateDynamicPersonGroup200Response | CreateDynamicPersonGroupDefaultResponse @@ -1422,14 +1422,14 @@ export interface CreateDynamicPersonGroupWithPerson { >; /** The properties keep unchanged if they are not in request body. */ patch( - options?: UpdateDynamicPersonGroupWithPersonChangesParameters, + options: UpdateDynamicPersonGroupWithPersonChangesParameters, ): StreamableMethod< | UpdateDynamicPersonGroupWithPersonChanges202Response | UpdateDynamicPersonGroupWithPersonChangesDefaultResponse >; /** The properties keep unchanged if they are not in request body. */ patch( - options?: UpdateDynamicPersonGroupParameters, + options: UpdateDynamicPersonGroupParameters, ): StreamableMethod< | UpdateDynamicPersonGroup200Response | UpdateDynamicPersonGroupDefaultResponse @@ -1495,7 +1495,7 @@ export interface CreateLivenessSession { * > Client access can be revoked by deleting the session using the Delete Liveness Session operation. To retrieve a result, use the Get Liveness Session. To audit the individual requests that a client has made to your resource, use the List Liveness Session Audit Entries. */ post( - options?: CreateLivenessSessionParameters, + options: CreateLivenessSessionParameters, ): StreamableMethod< CreateLivenessSession200Response | CreateLivenessSessionDefaultResponse >; @@ -1586,7 +1586,7 @@ export interface CreateLivenessWithVerifySessionWithVerifyImage { * > Extra measures should be taken to validate that the client is sending the expected VerifyImage. */ post( - options?: CreateLivenessWithVerifySessionParameters, + options: CreateLivenessWithVerifySessionParameters, ): StreamableMethod< | CreateLivenessWithVerifySession200Response | CreateLivenessWithVerifySessionDefaultResponse diff --git a/packages/typespec-test/test/faceai/generated/typespec-ts/src/parameters.ts b/packages/typespec-test/test/faceai/generated/typespec-ts/src/parameters.ts index 916b76c3ce..d85399f944 100644 --- a/packages/typespec-test/test/faceai/generated/typespec-ts/src/parameters.ts +++ b/packages/typespec-test/test/faceai/generated/typespec-ts/src/parameters.ts @@ -14,7 +14,7 @@ import { export type GetOperationResultParameters = RequestParameters; export interface DetectFromUrlBodyParam { - body?: { url: string }; + body: { url: string }; } export interface DetectFromUrlQueryParamProperties { @@ -109,7 +109,7 @@ export type DetectParameters = DetectQueryParam & RequestParameters; export interface FindSimilarBodyParam { - body?: { + body: { faceId: string; maxNumOfCandidatesReturned?: number; mode?: FindSimilarMatchMode; @@ -120,7 +120,7 @@ export interface FindSimilarBodyParam { export type FindSimilarParameters = FindSimilarBodyParam & RequestParameters; export interface FindSimilarFromFaceListBodyParam { - body?: { + body: { faceId: string; maxNumOfCandidatesReturned?: number; mode?: FindSimilarMatchMode; @@ -132,7 +132,7 @@ export type FindSimilarFromFaceListParameters = FindSimilarFromFaceListBodyParam & RequestParameters; export interface FindSimilarFromLargeFaceListBodyParam { - body?: { + body: { faceId: string; maxNumOfCandidatesReturned?: number; mode?: FindSimilarMatchMode; @@ -144,7 +144,7 @@ export type FindSimilarFromLargeFaceListParameters = FindSimilarFromLargeFaceListBodyParam & RequestParameters; export interface IdentifyFromPersonGroupBodyParam { - body?: { + body: { faceIds: string[]; personGroupId: string; maxNumOfCandidatesReturned?: number; @@ -156,7 +156,7 @@ export type IdentifyFromPersonGroupParameters = IdentifyFromPersonGroupBodyParam & RequestParameters; export interface IdentifyFromLargePersonGroupBodyParam { - body?: { + body: { faceIds: string[]; largePersonGroupId: string; maxNumOfCandidatesReturned?: number; @@ -168,7 +168,7 @@ export type IdentifyFromLargePersonGroupParameters = IdentifyFromLargePersonGroupBodyParam & RequestParameters; export interface IdentifyFromPersonDirectoryBodyParam { - body?: { + body: { faceIds: string[]; personIds: string[]; maxNumOfCandidatesReturned?: number; @@ -180,7 +180,7 @@ export type IdentifyFromPersonDirectoryParameters = IdentifyFromPersonDirectoryBodyParam & RequestParameters; export interface IdentifyFromDynamicPersonGroupBodyParam { - body?: { + body: { faceIds: string[]; dynamicPersonGroupId: string; maxNumOfCandidatesReturned?: number; @@ -192,41 +192,41 @@ export type IdentifyFromDynamicPersonGroupParameters = IdentifyFromDynamicPersonGroupBodyParam & RequestParameters; export interface VerifyFaceToFaceBodyParam { - body?: { faceId1: string; faceId2: string }; + body: { faceId1: string; faceId2: string }; } export type VerifyFaceToFaceParameters = VerifyFaceToFaceBodyParam & RequestParameters; export interface VerifyFromPersonGroupBodyParam { - body?: { faceId: string; personGroupId: string; personId: string }; + body: { faceId: string; personGroupId: string; personId: string }; } export type VerifyFromPersonGroupParameters = VerifyFromPersonGroupBodyParam & RequestParameters; export interface VerifyFromLargePersonGroupBodyParam { - body?: { faceId: string; largePersonGroupId: string; personId: string }; + body: { faceId: string; largePersonGroupId: string; personId: string }; } export type VerifyFromLargePersonGroupParameters = VerifyFromLargePersonGroupBodyParam & RequestParameters; export interface VerifyFromPersonDirectoryBodyParam { - body?: { faceId: string; personId: string }; + body: { faceId: string; personId: string }; } export type VerifyFromPersonDirectoryParameters = VerifyFromPersonDirectoryBodyParam & RequestParameters; export interface GroupBodyParam { - body?: { faceIds: string[] }; + body: { faceIds: string[] }; } export type GroupParameters = GroupBodyParam & RequestParameters; export interface CreateFaceListBodyParam { - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -249,7 +249,7 @@ export interface GetFaceListQueryParam { export type GetFaceListParameters = GetFaceListQueryParam & RequestParameters; export interface UpdateFaceListBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdateFaceListParameters = UpdateFaceListBodyParam & @@ -267,7 +267,7 @@ export interface GetFaceListsQueryParam { export type GetFaceListsParameters = GetFaceListsQueryParam & RequestParameters; export interface AddFaceListFaceFromUrlBodyParam { - body?: { url: string }; + body: { url: string }; } export interface AddFaceListFaceFromUrlQueryParamProperties { @@ -334,7 +334,7 @@ export type AddFaceListFaceParameters = AddFaceListFaceQueryParam & export type DeleteFaceListFaceParameters = RequestParameters; export interface CreateLargeFaceListBodyParam { - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -358,7 +358,7 @@ export type GetLargeFaceListParameters = GetLargeFaceListQueryParam & RequestParameters; export interface UpdateLargeFaceListBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdateLargeFaceListParameters = UpdateLargeFaceListBodyParam & @@ -383,7 +383,7 @@ export type GetLargeFaceListTrainingStatusParameters = RequestParameters; export type TrainLargeFaceListParameters = RequestParameters; export interface AddLargeFaceListFaceFromUrlBodyParam { - body?: { url: string }; + body: { url: string }; } export interface AddLargeFaceListFaceFromUrlQueryParamProperties { @@ -451,7 +451,7 @@ export type DeleteLargeFaceListFaceParameters = RequestParameters; export type GetLargeFaceListFaceParameters = RequestParameters; export interface UpdateLargeFaceListFaceBodyParam { - body?: { userData?: string }; + body: { userData?: string }; } export type UpdateLargeFaceListFaceParameters = @@ -472,7 +472,7 @@ export type GetLargeFaceListFacesParameters = GetLargeFaceListFacesQueryParam & RequestParameters; export interface CreatePersonGroupBodyParam { - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -496,7 +496,7 @@ export type GetPersonGroupParameters = GetPersonGroupQueryParam & RequestParameters; export interface UpdatePersonGroupBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdatePersonGroupParameters = UpdatePersonGroupBodyParam & @@ -521,7 +521,7 @@ export type GetPersonGroupTrainingStatusParameters = RequestParameters; export type TrainPersonGroupParameters = RequestParameters; export interface CreatePersonGroupPersonBodyParam { - body?: { name: string; userData?: string }; + body: { name: string; userData?: string }; } export type CreatePersonGroupPersonParameters = @@ -530,7 +530,7 @@ export type DeletePersonGroupPersonParameters = RequestParameters; export type GetPersonGroupPersonParameters = RequestParameters; export interface UpdatePersonGroupPersonBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdatePersonGroupPersonParameters = @@ -551,7 +551,7 @@ export type GetPersonGroupPersonsParameters = GetPersonGroupPersonsQueryParam & RequestParameters; export interface AddPersonGroupPersonFaceFromUrlBodyParam { - body?: { url: string }; + body: { url: string }; } export interface AddPersonGroupPersonFaceFromUrlQueryParamProperties { @@ -620,14 +620,14 @@ export type DeletePersonGroupPersonFaceParameters = RequestParameters; export type GetPersonGroupPersonFaceParameters = RequestParameters; export interface UpdatePersonGroupPersonFaceBodyParam { - body?: { userData?: string }; + body: { userData?: string }; } export type UpdatePersonGroupPersonFaceParameters = UpdatePersonGroupPersonFaceBodyParam & RequestParameters; export interface CreateLargePersonGroupBodyParam { - body?: { + body: { name: string; userData?: string; recognitionModel?: RecognitionModel; @@ -651,7 +651,7 @@ export type GetLargePersonGroupParameters = GetLargePersonGroupQueryParam & RequestParameters; export interface UpdateLargePersonGroupBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdateLargePersonGroupParameters = UpdateLargePersonGroupBodyParam & @@ -676,7 +676,7 @@ export type GetLargePersonGroupTrainingStatusParameters = RequestParameters; export type TrainLargePersonGroupParameters = RequestParameters; export interface CreateLargePersonGroupPersonBodyParam { - body?: { name: string; userData?: string }; + body: { name: string; userData?: string }; } export type CreateLargePersonGroupPersonParameters = @@ -685,7 +685,7 @@ export type DeleteLargePersonGroupPersonParameters = RequestParameters; export type GetLargePersonGroupPersonParameters = RequestParameters; export interface UpdateLargePersonGroupPersonBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdateLargePersonGroupPersonParameters = @@ -706,7 +706,7 @@ export type GetLargePersonGroupPersonsParameters = GetLargePersonGroupPersonsQueryParam & RequestParameters; export interface AddLargePersonGroupPersonFaceFromUrlBodyParam { - body?: { url: string }; + body: { url: string }; } export interface AddLargePersonGroupPersonFaceFromUrlQueryParamProperties { @@ -775,14 +775,14 @@ export type DeleteLargePersonGroupPersonFaceParameters = RequestParameters; export type GetLargePersonGroupPersonFaceParameters = RequestParameters; export interface UpdateLargePersonGroupPersonFaceBodyParam { - body?: { userData?: string }; + body: { userData?: string }; } export type UpdateLargePersonGroupPersonFaceParameters = UpdateLargePersonGroupPersonFaceBodyParam & RequestParameters; export interface CreatePersonBodyParam { - body?: { name: string; userData?: string }; + body: { name: string; userData?: string }; } export type CreatePersonParameters = CreatePersonBodyParam & RequestParameters; @@ -790,7 +790,7 @@ export type DeletePersonParameters = RequestParameters; export type GetPersonParameters = RequestParameters; export interface UpdatePersonBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdatePersonParameters = UpdatePersonBodyParam & RequestParameters; @@ -863,7 +863,7 @@ export type AddPersonFaceParameters = AddPersonFaceQueryParam & RequestParameters; export interface AddPersonFaceFromUrlBodyParam { - body?: { url: string }; + body: { url: string }; } export interface AddPersonFaceFromUrlQueryParamProperties { @@ -890,7 +890,7 @@ export type DeletePersonFaceParameters = RequestParameters; export type GetPersonFaceParameters = RequestParameters; export interface UpdatePersonFaceBodyParam { - body?: { userData?: string }; + body: { userData?: string }; } export type UpdatePersonFaceParameters = UpdatePersonFaceBodyParam & @@ -898,14 +898,14 @@ export type UpdatePersonFaceParameters = UpdatePersonFaceBodyParam & export type GetPersonFacesParameters = RequestParameters; export interface CreateDynamicPersonGroupWithPersonBodyParam { - body?: { name: string; userData?: string; addPersonIds: string[] }; + body: { name: string; userData?: string; addPersonIds: string[] }; } export type CreateDynamicPersonGroupWithPersonParameters = CreateDynamicPersonGroupWithPersonBodyParam & RequestParameters; export interface CreateDynamicPersonGroupBodyParam { - body?: { name: string; userData?: string }; + body: { name: string; userData?: string }; } export type CreateDynamicPersonGroupParameters = @@ -914,7 +914,7 @@ export type DeleteDynamicPersonGroupParameters = RequestParameters; export type GetDynamicPersonGroupParameters = RequestParameters; export interface UpdateDynamicPersonGroupWithPersonChangesBodyParam { - body?: { + body: { name?: string; userData?: string; addPersonIds?: string[]; @@ -926,7 +926,7 @@ export type UpdateDynamicPersonGroupWithPersonChangesParameters = UpdateDynamicPersonGroupWithPersonChangesBodyParam & RequestParameters; export interface UpdateDynamicPersonGroupBodyParam { - body?: { name?: string; userData?: string }; + body: { name?: string; userData?: string }; } export type UpdateDynamicPersonGroupParameters = @@ -961,7 +961,7 @@ export type GetDynamicPersonGroupPersonsParameters = GetDynamicPersonGroupPersonsQueryParam & RequestParameters; export interface CreateLivenessSessionBodyParam { - body?: LivenessSessionCreationContent; + body: LivenessSessionCreationContent; } export type CreateLivenessSessionParameters = CreateLivenessSessionBodyParam & @@ -998,7 +998,7 @@ export type GetLivenessSessionAuditEntriesParameters = GetLivenessSessionAuditEntriesQueryParam & RequestParameters; export interface CreateLivenessWithVerifySessionWithVerifyImageBodyParam { - body?: LivenessSessionWithVerifyImageCreationContent; + body: LivenessSessionWithVerifyImageCreationContent; } export interface CreateLivenessWithVerifySessionWithVerifyImageMediaTypesParam { @@ -1012,7 +1012,7 @@ export type CreateLivenessWithVerifySessionWithVerifyImageParameters = RequestParameters; export interface CreateLivenessWithVerifySessionBodyParam { - body?: LivenessSessionCreationContent; + body: LivenessSessionCreationContent; } export type CreateLivenessWithVerifySessionParameters = diff --git a/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/review/health-insights-radiologyinsights.api.md b/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/review/health-insights-radiologyinsights.api.md index bd62d5a3f1..6e18457117 100644 --- a/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/review/health-insights-radiologyinsights.api.md +++ b/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/review/health-insights-radiologyinsights.api.md @@ -212,7 +212,7 @@ export default createClient; // @public (undocumented) export interface CreateJob { - post(options?: CreateJobParameters): StreamableMethod; + post(options: CreateJobParameters): StreamableMethod; } // @public (undocumented) @@ -235,7 +235,7 @@ export interface CreateJob202Response extends HttpResponse { // @public (undocumented) export interface CreateJobBodyParam { // (undocumented) - body?: RadiologyInsightsData; + body: RadiologyInsightsData; } // @public (undocumented) diff --git a/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/clientDefinitions.ts b/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/clientDefinitions.ts index ff01257da2..29449a5101 100644 --- a/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/clientDefinitions.ts +++ b/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/clientDefinitions.ts @@ -20,7 +20,7 @@ export interface GetJob { export interface CreateJob { /** Creates a Radiology Insights job with the given request body. */ post( - options?: CreateJobParameters, + options: CreateJobParameters, ): StreamableMethod; } diff --git a/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/parameters.ts b/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/parameters.ts index 74248e6d86..33d419e15c 100644 --- a/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/parameters.ts +++ b/packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/parameters.ts @@ -15,7 +15,7 @@ export interface CreateJobHeaders { } export interface CreateJobBodyParam { - body?: RadiologyInsightsData; + body: RadiologyInsightsData; } export interface CreateJobHeaderParam { diff --git a/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/review/health-insights-clinicalmatching.api.md b/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/review/health-insights-clinicalmatching.api.md index d3fe9ad5cd..983cf16df6 100644 --- a/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/review/health-insights-clinicalmatching.api.md +++ b/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/review/health-insights-clinicalmatching.api.md @@ -196,7 +196,7 @@ export default createClient; // @public (undocumented) export interface CreateJob { - post(options?: CreateJobParameters): StreamableMethod; + post(options: CreateJobParameters): StreamableMethod; } // @public @@ -225,7 +225,7 @@ export interface CreateJob202Response extends HttpResponse { // @public (undocumented) export interface CreateJobBodyParam { // (undocumented) - body?: TrialMatcherData; + body: TrialMatcherData; } // @public (undocumented) diff --git a/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/clientDefinitions.ts b/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/clientDefinitions.ts index 9375430a89..16d22c0417 100644 --- a/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/clientDefinitions.ts +++ b/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/clientDefinitions.ts @@ -21,7 +21,7 @@ export interface GetJob { export interface CreateJob { /** Creates a Trial Matcher job with the given request body. */ post( - options?: CreateJobParameters, + options: CreateJobParameters, ): StreamableMethod< CreateJob200Response | CreateJob202Response | CreateJobDefaultResponse >; diff --git a/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/parameters.ts b/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/parameters.ts index aa3a574bb8..877ccdb349 100644 --- a/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/parameters.ts +++ b/packages/typespec-test/test/healthInsights_trialmatcher/generated/typespec-ts/src/parameters.ts @@ -15,7 +15,7 @@ export interface CreateJobHeaders { } export interface CreateJobBodyParam { - body?: TrialMatcherData; + body: TrialMatcherData; } export interface CreateJobHeaderParam { diff --git a/packages/typespec-test/test/openai/generated/typespec-ts/review/openai.api.md b/packages/typespec-test/test/openai/generated/typespec-ts/review/openai.api.md index 4ee970948e..c99e745d38 100644 --- a/packages/typespec-test/test/openai/generated/typespec-ts/review/openai.api.md +++ b/packages/typespec-test/test/openai/generated/typespec-ts/review/openai.api.md @@ -53,7 +53,7 @@ export interface BatchImageGenerationOperationResponseOutput { // @public (undocumented) export interface BeginAzureBatchImageGeneration { - post(options?: BeginAzureBatchImageGenerationParameters): StreamableMethod; + post(options: BeginAzureBatchImageGenerationParameters): StreamableMethod; } // @public (undocumented) @@ -74,7 +74,7 @@ export interface BeginAzureBatchImageGeneration202Response extends HttpResponse // @public (undocumented) export interface BeginAzureBatchImageGenerationBodyParam { // (undocumented) - body?: ImageGenerationOptions; + body: ImageGenerationOptions; } // @public (undocumented) @@ -325,7 +325,7 @@ export type GetAzureBatchImageGenerationOperationStatusParameters = RequestParam // @public (undocumented) export interface GetChatCompletions { - post(options?: GetChatCompletionsParameters): StreamableMethod; + post(options: GetChatCompletionsParameters): StreamableMethod; } // @public @@ -339,7 +339,7 @@ export interface GetChatCompletions200Response extends HttpResponse { // @public (undocumented) export interface GetChatCompletionsBodyParam { // (undocumented) - body?: ChatCompletionsOptions; + body: ChatCompletionsOptions; } // @public (undocumented) @@ -362,7 +362,7 @@ export type GetChatCompletionsParameters = GetChatCompletionsBodyParam & Request // @public (undocumented) export interface GetChatCompletionsWithAzureExtensions { - post(options?: GetChatCompletionsWithAzureExtensionsParameters): StreamableMethod; + post(options: GetChatCompletionsWithAzureExtensionsParameters): StreamableMethod; } // @public @@ -376,7 +376,7 @@ export interface GetChatCompletionsWithAzureExtensions200Response extends HttpRe // @public (undocumented) export interface GetChatCompletionsWithAzureExtensionsBodyParam { // (undocumented) - body?: ChatCompletionsOptions; + body: ChatCompletionsOptions; } // @public (undocumented) @@ -399,7 +399,7 @@ export type GetChatCompletionsWithAzureExtensionsParameters = GetChatCompletions // @public (undocumented) export interface GetCompletions { - post(options?: GetCompletionsParameters): StreamableMethod; + post(options: GetCompletionsParameters): StreamableMethod; } // @public @@ -413,7 +413,7 @@ export interface GetCompletions200Response extends HttpResponse { // @public (undocumented) export interface GetCompletionsBodyParam { // (undocumented) - body?: CompletionsOptions; + body: CompletionsOptions; } // @public (undocumented) @@ -436,7 +436,7 @@ export type GetCompletionsParameters = GetCompletionsBodyParam & RequestParamete // @public (undocumented) export interface GetEmbeddings { - post(options?: GetEmbeddingsParameters): StreamableMethod; + post(options: GetEmbeddingsParameters): StreamableMethod; } // @public @@ -450,7 +450,7 @@ export interface GetEmbeddings200Response extends HttpResponse { // @public (undocumented) export interface GetEmbeddingsBodyParam { // (undocumented) - body?: EmbeddingsOptions; + body: EmbeddingsOptions; } // @public (undocumented) diff --git a/packages/typespec-test/test/openai/generated/typespec-ts/src/clientDefinitions.ts b/packages/typespec-test/test/openai/generated/typespec-ts/src/clientDefinitions.ts index f9547d4de4..9d14d797a9 100644 --- a/packages/typespec-test/test/openai/generated/typespec-ts/src/clientDefinitions.ts +++ b/packages/typespec-test/test/openai/generated/typespec-ts/src/clientDefinitions.ts @@ -28,7 +28,7 @@ import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface GetEmbeddings { /** Return the embeddings for a given prompt. */ post( - options?: GetEmbeddingsParameters, + options: GetEmbeddingsParameters, ): StreamableMethod; } @@ -39,7 +39,7 @@ export interface GetCompletions { * provided prompt data. */ post( - options?: GetCompletionsParameters, + options: GetCompletionsParameters, ): StreamableMethod< GetCompletions200Response | GetCompletionsDefaultResponse >; @@ -52,7 +52,7 @@ export interface GetChatCompletions { * provided prompt data. */ post( - options?: GetChatCompletionsParameters, + options: GetChatCompletionsParameters, ): StreamableMethod< GetChatCompletions200Response | GetChatCompletionsDefaultResponse >; @@ -65,7 +65,7 @@ export interface GetChatCompletionsWithAzureExtensions { * other augmentations to the base chat completions capabilities. */ post( - options?: GetChatCompletionsWithAzureExtensionsParameters, + options: GetChatCompletionsWithAzureExtensionsParameters, ): StreamableMethod< | GetChatCompletionsWithAzureExtensions200Response | GetChatCompletionsWithAzureExtensionsDefaultResponse @@ -85,7 +85,7 @@ export interface GetAzureBatchImageGenerationOperationStatus { export interface BeginAzureBatchImageGeneration { /** Starts the generation of a batch of images from a text caption */ post( - options?: BeginAzureBatchImageGenerationParameters, + options: BeginAzureBatchImageGenerationParameters, ): StreamableMethod< | BeginAzureBatchImageGeneration202Response | BeginAzureBatchImageGenerationDefaultResponse diff --git a/packages/typespec-test/test/openai/generated/typespec-ts/src/parameters.ts b/packages/typespec-test/test/openai/generated/typespec-ts/src/parameters.ts index f21e5cc8ce..5d3eca775a 100644 --- a/packages/typespec-test/test/openai/generated/typespec-ts/src/parameters.ts +++ b/packages/typespec-test/test/openai/generated/typespec-ts/src/parameters.ts @@ -10,28 +10,28 @@ import { } from "./models.js"; export interface GetEmbeddingsBodyParam { - body?: EmbeddingsOptions; + body: EmbeddingsOptions; } export type GetEmbeddingsParameters = GetEmbeddingsBodyParam & RequestParameters; export interface GetCompletionsBodyParam { - body?: CompletionsOptions; + body: CompletionsOptions; } export type GetCompletionsParameters = GetCompletionsBodyParam & RequestParameters; export interface GetChatCompletionsBodyParam { - body?: ChatCompletionsOptions; + body: ChatCompletionsOptions; } export type GetChatCompletionsParameters = GetChatCompletionsBodyParam & RequestParameters; export interface GetChatCompletionsWithAzureExtensionsBodyParam { - body?: ChatCompletionsOptions; + body: ChatCompletionsOptions; } export type GetChatCompletionsWithAzureExtensionsParameters = @@ -40,7 +40,7 @@ export type GetAzureBatchImageGenerationOperationStatusParameters = RequestParameters; export interface BeginAzureBatchImageGenerationBodyParam { - body?: ImageGenerationOptions; + body: ImageGenerationOptions; } export type BeginAzureBatchImageGenerationParameters = diff --git a/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/review/todo-non-branded.api.md b/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/review/todo-non-branded.api.md index 5748bafaf8..732e2ce5ac 100644 --- a/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/review/todo-non-branded.api.md +++ b/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/review/todo-non-branded.api.md @@ -111,7 +111,7 @@ export interface TodoItemsAttachmentsCreateFileAttachment404Response extends Htt // @public (undocumented) export interface TodoItemsAttachmentsCreateFileAttachmentBodyParam { // (undocumented) - body?: FormData | Array<{ + body: FormData | Array<{ name: "contents"; body: string | Uint8Array | ReadableStream | NodeJS.ReadableStream | File; filename?: string; @@ -143,7 +143,7 @@ export interface TodoItemsAttachmentsCreateUrlAttachment404Response extends Http // @public (undocumented) export interface TodoItemsAttachmentsCreateUrlAttachmentBodyParam { // (undocumented) - body?: { + body: { contents: TodoUrlAttachment; }; } @@ -203,7 +203,7 @@ export interface TodoItemsCreateForm422Response extends HttpResponse { // @public (undocumented) export interface TodoItemsCreateFormBodyParam { // (undocumented) - body?: FormData | Array<{ + body: FormData | Array<{ name: "item"; body: TodoItem; } | { @@ -242,7 +242,7 @@ export interface TodoItemsCreateJson422Response extends HttpResponse { // @public (undocumented) export interface TodoItemsCreateJsonBodyParam { // (undocumented) - body?: { + body: { item: TodoItem; attachments: Array; }; @@ -343,7 +343,7 @@ export interface TodoItemsUpdate200Response extends HttpResponse { // @public (undocumented) export interface TodoItemsUpdateBodyParam { // (undocumented) - body?: { + body: { patch: TodoItemPatch; }; } @@ -426,7 +426,7 @@ export interface UserExistsResponseOutput extends ErrorModelOutput { // @public (undocumented) export interface UsersCreate { // (undocumented) - post(options?: UsersCreateParameters): StreamableMethod; + post(options: UsersCreateParameters): StreamableMethod; } // @public @@ -456,7 +456,7 @@ export interface UsersCreate422Response extends HttpResponse { // @public (undocumented) export interface UsersCreateBodyParam { // (undocumented) - body?: { + body: { user: User; }; } @@ -466,7 +466,7 @@ export type UsersCreateParameters = UsersCreateBodyParam & RequestParameters; // @public (undocumented) export interface UsersForgotPassword { - post(options?: UsersForgotPasswordParameters): StreamableMethod; + post(options: UsersForgotPasswordParameters): StreamableMethod; } // @public @@ -484,7 +484,7 @@ export interface UsersForgotPassword404Response extends HttpResponse { // @public (undocumented) export interface UsersForgotPasswordBodyParam { // (undocumented) - body?: { + body: { email: string; }; } @@ -495,7 +495,7 @@ export type UsersForgotPasswordParameters = UsersForgotPasswordBodyParam & Reque // @public (undocumented) export interface UsersLogin { // (undocumented) - post(options?: UsersLoginParameters): StreamableMethod; + post(options: UsersLoginParameters): StreamableMethod; } // @public @@ -513,7 +513,7 @@ export interface UsersLogin401Response extends HttpResponse { // @public (undocumented) export interface UsersLoginBodyParam { // (undocumented) - body?: { + body: { username: string; password: string; }; diff --git a/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/clientDefinitions.ts b/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/clientDefinitions.ts index da3a208a4a..4f2a175d34 100644 --- a/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/clientDefinitions.ts +++ b/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/clientDefinitions.ts @@ -51,7 +51,7 @@ import { Client, StreamableMethod } from "@typespec/ts-http-runtime"; export interface UsersCreate { post( - options?: UsersCreateParameters, + options: UsersCreateParameters, ): StreamableMethod< UsersCreate200Response | UsersCreate409Response | UsersCreate422Response >; @@ -65,7 +65,7 @@ export interface UsersValidate { export interface UsersLogin { post( - options?: UsersLoginParameters, + options: UsersLoginParameters, ): StreamableMethod; } @@ -78,7 +78,7 @@ export interface UsersLogout { export interface UsersForgotPassword { /** Sends a reset token to the user's email address */ post( - options?: UsersForgotPasswordParameters, + options: UsersForgotPasswordParameters, ): StreamableMethod< UsersForgotPassword200Response | UsersForgotPassword404Response >; diff --git a/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/parameters.ts b/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/parameters.ts index 5585d8aebc..6961f6d1dd 100644 --- a/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/parameters.ts +++ b/packages/typespec-test/test/todo_non_branded/generated/typespec-ts/src/parameters.ts @@ -4,7 +4,7 @@ import { RequestParameters } from "@typespec/ts-http-runtime"; import { User, TodoItem, TodoUrlAttachment, TodoItemPatch } from "./models.js"; export interface UsersCreateBodyParam { - body?: { user: User }; + body: { user: User }; } export type UsersCreateParameters = UsersCreateBodyParam & RequestParameters; @@ -21,14 +21,14 @@ export type UsersValidateParameters = UsersValidateQueryParam & RequestParameters; export interface UsersLoginBodyParam { - body?: { username: string; password: string }; + body: { username: string; password: string }; } export type UsersLoginParameters = UsersLoginBodyParam & RequestParameters; export type UsersLogoutParameters = RequestParameters; export interface UsersForgotPasswordBodyParam { - body?: { email: string }; + body: { email: string }; } export type UsersForgotPasswordParameters = UsersForgotPasswordBodyParam & @@ -60,7 +60,7 @@ export type TodoItemsListParameters = TodoItemsListQueryParam & RequestParameters; export interface TodoItemsCreateJsonBodyParam { - body?: { item: TodoItem; attachments: Array }; + body: { item: TodoItem; attachments: Array }; } export interface TodoItemsCreateJsonMediaTypesParam { @@ -72,7 +72,7 @@ export type TodoItemsCreateJsonParameters = TodoItemsCreateJsonMediaTypesParam & RequestParameters; export interface TodoItemsCreateFormBodyParam { - body?: + body: | FormData | Array< | { name: "item"; body: TodoItem } @@ -101,7 +101,7 @@ export type TodoItemsCreateFormParameters = TodoItemsCreateFormMediaTypesParam & export type TodoItemsGetParameters = RequestParameters; export interface TodoItemsUpdateBodyParam { - body?: { patch: TodoItemPatch }; + body: { patch: TodoItemPatch }; } export interface TodoItemsUpdateMediaTypesParam { @@ -115,7 +115,7 @@ export type TodoItemsDeleteParameters = RequestParameters; export type TodoItemsAttachmentsListParameters = RequestParameters; export interface TodoItemsAttachmentsCreateUrlAttachmentBodyParam { - body?: { contents: TodoUrlAttachment }; + body: { contents: TodoUrlAttachment }; } export interface TodoItemsAttachmentsCreateUrlAttachmentMediaTypesParam { @@ -128,7 +128,7 @@ export type TodoItemsAttachmentsCreateUrlAttachmentParameters = RequestParameters; export interface TodoItemsAttachmentsCreateFileAttachmentBodyParam { - body?: + body: | FormData | Array<{ name: "contents"; diff --git a/packages/typespec-ts/src/transform/transformParameters.ts b/packages/typespec-ts/src/transform/transformParameters.ts index 90a1711c4d..4df60c4867 100644 --- a/packages/typespec-ts/src/transform/transformParameters.ts +++ b/packages/typespec-ts/src/transform/transformParameters.ts @@ -11,41 +11,42 @@ import { Schema, SchemaContext } from "@azure-tools/rlc-common"; -import { isVoidType, Type } from "@typespec/compiler"; import { HttpOperation, HttpOperationParameter, HttpOperationParameters } from "@typespec/http"; import { - getBodyType, - getFormattedPropertyDoc, - getImportedModelName, - getSchemaForType, - getSerializeTypeName, - getTypeName -} from "../utils/modelUtils.js"; - + KnownMediaType, + extractMediaTypes, + hasMediaType, + isMediaTypeJsonMergePatch +} from "../utils/mediaTypes.js"; import { + SdkClient, getHttpOperationWithCache, isApiVersion, listOperationGroups, - listOperationsInOperationGroup, - SdkClient + listOperationsInOperationGroup } from "@azure-tools/typespec-client-generator-core"; -import { SdkContext } from "../utils/interfaces.js"; +import { Type, isVoidType } from "@typespec/compiler"; import { - extractMediaTypes, - hasMediaType, - isMediaTypeJsonMergePatch, - KnownMediaType -} from "../utils/mediaTypes.js"; + getBodyType, + getFormattedPropertyDoc, + getImportedModelName, + getSchemaForType, + getSerializeTypeName, + getTypeName, + isBodyRequired +} from "../utils/modelUtils.js"; import { getOperationGroupName, getOperationName, getSpecialSerializeInfo } from "../utils/operationUtil.js"; +import { SdkContext } from "../utils/interfaces.js"; + export function transformToParameterTypes( client: SdkClient, dpgContext: SdkContext, @@ -295,7 +296,7 @@ function transformRequestBody( typeName: schema.name, name: "body", type, - required: parameters?.bodyParameter?.optional === false, + required: isBodyRequired(parameters), description: descriptions.join("\n\n"), isMultipartBody: hasMediaType(KnownMediaType.MultipartFormData, contentTypes) && diff --git a/packages/typespec-ts/src/transform/transformPaths.ts b/packages/typespec-ts/src/transform/transformPaths.ts index 5d267d162d..d6b97eddb8 100644 --- a/packages/typespec-ts/src/transform/transformPaths.ts +++ b/packages/typespec-ts/src/transform/transformPaths.ts @@ -1,30 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import { HttpOperation, HttpOperationParameters } from "@typespec/http"; import { - getParameterTypeName, - getResponseTypeName, Imports, OperationMethod, PathMetadata, Paths, - SchemaContext + SchemaContext, + getParameterTypeName, + getResponseTypeName } from "@azure-tools/rlc-common"; import { + SdkClient, getHttpOperationWithCache, isApiVersion, listOperationGroups, - listOperationsInOperationGroup, - SdkClient + listOperationsInOperationGroup } from "@azure-tools/typespec-client-generator-core"; -import { getDoc } from "@typespec/compiler"; -import { HttpOperation, HttpOperationParameters } from "@typespec/http"; -import { SdkContext } from "../utils/interfaces.js"; -import { - getImportedModelName, - getSchemaForType, - getTypeName -} from "../utils/modelUtils.js"; import { extractOperationLroDetail, getOperationGroupName, @@ -35,6 +28,15 @@ import { isPagingOperation, sortedOperationResponses } from "../utils/operationUtil.js"; +import { + getImportedModelName, + getSchemaForType, + getTypeName, + isBodyRequired +} from "../utils/modelUtils.js"; + +import { SdkContext } from "../utils/interfaces.js"; +import { getDoc } from "@typespec/compiler"; export function transformPaths( client: SdkClient, @@ -160,7 +162,8 @@ function hasRequiredOptions( dpgContext: SdkContext, routeParameters: HttpOperationParameters ) { - const isRequiredBodyParam = routeParameters.bodyParameter?.optional === false; + const isRequiredBodyParam = isBodyRequired(routeParameters); + const containsRequiredNonBodyParam = routeParameters.parameters .filter((parameter) => ["query", "header"].includes(parameter.type)) .filter((parameter) => !isApiVersion(dpgContext, parameter)) diff --git a/packages/typespec-ts/src/utils/modelUtils.ts b/packages/typespec-ts/src/utils/modelUtils.ts index a57f496a0e..847d6d76ee 100644 --- a/packages/typespec-ts/src/utils/modelUtils.ts +++ b/packages/typespec-ts/src/utils/modelUtils.ts @@ -4,28 +4,30 @@ import { ArraySchema, DictionarySchema, - isArraySchema, NameType, - normalizeName, ObjectSchema, Schema, - SchemaContext + SchemaContext, + isArraySchema, + normalizeName } from "@azure-tools/rlc-common"; -import { - getPagedResult, - getUnionAsEnum -} from "@azure-tools/typespec-azure-core"; -import { - getDefaultApiVersion, - getWireName, - isApiVersion -} from "@azure-tools/typespec-client-generator-core"; import { BooleanLiteral, Discriminator, EncodeData, Enum, EnumMember, + Model, + ModelProperty, + NoTarget, + NumericLiteral, + Program, + Scalar, + Service, + StringLiteral, + Type, + Union, + UnionVariant, getDiscriminator, getDoc, getEffectiveModelType, @@ -49,37 +51,37 @@ import { isSecret, isStringType, isTemplateDeclaration, + isType, isUnknownType, - listServices, - Model, - ModelProperty, - NoTarget, - NumericLiteral, - Program, - Scalar, - Service, - StringLiteral, - Type, - Union, - UnionVariant, - isType + listServices } from "@typespec/compiler"; +import { GetSchemaOptions, SdkContext } from "./interfaces.js"; import { + HttpOperation, + HttpOperationParameters, getHeaderFieldName, getPathParamName, getQueryParamName, - HttpOperation, isStatusCode } from "@typespec/http"; -import { reportDiagnostic } from "../lib.js"; -import { GetSchemaOptions, SdkContext } from "./interfaces.js"; import { + KnownMediaType, hasMediaType, - isMediaTypeMultipartFormData, - KnownMediaType + isMediaTypeMultipartFormData } from "./mediaTypes.js"; -import { getModelNamespaceName } from "./namespaceUtils.js"; +import { + getDefaultApiVersion, + getWireName, + isApiVersion +} from "@azure-tools/typespec-client-generator-core"; +import { + getPagedResult, + getUnionAsEnum +} from "@azure-tools/typespec-azure-core"; + import { extractPagedMetadataNested } from "./operationUtil.js"; +import { getModelNamespaceName } from "./namespaceUtils.js"; +import { reportDiagnostic } from "../lib.js"; export const BINARY_TYPE_UNION = "string | Uint8Array | ReadableStream | NodeJS.ReadableStream"; @@ -1802,3 +1804,9 @@ export function getEffectiveSchemaType( } return type as Model; } + +export function isBodyRequired(parameter: HttpOperationParameters) { + return parameter.body?.type && parameter.body?.property?.optional !== true + ? true + : false; +} diff --git a/packages/typespec-ts/test/integration/clientStructure.spec.ts b/packages/typespec-ts/test/integration/clientStructure.spec.ts index ec0569bbc0..7a3d5e5abd 100644 --- a/packages/typespec-ts/test/integration/clientStructure.spec.ts +++ b/packages/typespec-ts/test/integration/clientStructure.spec.ts @@ -114,12 +114,12 @@ describe("ClientStructureClient Rest Client", () => { }); it("should call operation seven correctly", async () => { - try { - const result = await client0.path("/seven").post(); - assert.strictEqual(result.status, "204"); - } catch (err) { - assert.fail(err as string); - } + try { + const result = await client0.path("/seven").post(); + assert.strictEqual(result.status, "204"); + } catch (err) { + assert.fail(err as string); + } }); it("should call operation eight correctly", async () => { diff --git a/packages/typespec-ts/test/integration/generated/overload/src/index.d.ts b/packages/typespec-ts/test/integration/generated/overload/src/index.d.ts index 434c6286b9..640bed5005 100644 --- a/packages/typespec-ts/test/integration/generated/overload/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/overload/src/index.d.ts @@ -38,7 +38,7 @@ export declare interface Process204Response extends HttpResponse { } export declare interface ProcessBodyParam { - body?: { + body: { data: string | string; }; } diff --git a/packages/typespec-ts/test/integration/generated/parameters/basic/src/index.d.ts b/packages/typespec-ts/test/integration/generated/parameters/basic/src/index.d.ts index c7022c11e1..f483d72a8e 100644 --- a/packages/typespec-ts/test/integration/generated/parameters/basic/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/parameters/basic/src/index.d.ts @@ -29,7 +29,7 @@ export declare interface ExplicitBodySimpleBodyParam { export declare type ExplicitBodySimpleParameters = ExplicitBodySimpleBodyParam & RequestParameters; export declare interface ImplicitBodySimple { - put(options?: ImplicitBodySimpleParameters): StreamableMethod; + put(options: ImplicitBodySimpleParameters): StreamableMethod; } export declare interface ImplicitBodySimple204Response extends HttpResponse { @@ -37,7 +37,7 @@ export declare interface ImplicitBodySimple204Response extends HttpResponse { } export declare interface ImplicitBodySimpleBodyParam { - body?: { + body: { name: string; }; } diff --git a/packages/typespec-ts/test/integration/generated/parameters/body-optionality/src/index.d.ts b/packages/typespec-ts/test/integration/generated/parameters/body-optionality/src/index.d.ts index 95d0eea80d..bcbc9838e7 100644 --- a/packages/typespec-ts/test/integration/generated/parameters/body-optionality/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/parameters/body-optionality/src/index.d.ts @@ -58,7 +58,7 @@ export declare interface RequiredExplicitBodyParam { export declare type RequiredExplicitParameters = RequiredExplicitBodyParam & RequestParameters; export declare interface RequiredImplicit { - post(options?: RequiredImplicitParameters): StreamableMethod; + post(options: RequiredImplicitParameters): StreamableMethod; } export declare interface RequiredImplicit204Response extends HttpResponse { @@ -66,7 +66,7 @@ export declare interface RequiredImplicit204Response extends HttpResponse { } export declare interface RequiredImplicitBodyParam { - body?: BodyModel; + body: BodyModel; } export declare type RequiredImplicitParameters = RequiredImplicitBodyParam & RequestParameters; diff --git a/packages/typespec-ts/test/integration/generated/parameters/spread/src/index.d.ts b/packages/typespec-ts/test/integration/generated/parameters/spread/src/index.d.ts index 67c70fa22a..f91256336f 100644 --- a/packages/typespec-ts/test/integration/generated/parameters/spread/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/parameters/spread/src/index.d.ts @@ -6,7 +6,7 @@ import { RequestParameters } from '@azure-rest/core-client'; import { StreamableMethod } from '@azure-rest/core-client'; export declare interface AliasSpreadAsRequestBody { - put(options?: AliasSpreadAsRequestBodyParameters): StreamableMethod; + put(options: AliasSpreadAsRequestBodyParameters): StreamableMethod; } export declare interface AliasSpreadAsRequestBody204Response extends HttpResponse { @@ -14,7 +14,7 @@ export declare interface AliasSpreadAsRequestBody204Response extends HttpRespons } export declare interface AliasSpreadAsRequestBodyBodyParam { - body?: { + body: { name: string; }; } @@ -30,7 +30,7 @@ export declare interface AliasSpreadAsRequestParameter204Response extends HttpRe } export declare interface AliasSpreadAsRequestParameterBodyParam { - body?: { + body: { name: string; }; } @@ -54,7 +54,7 @@ export declare interface AliasSpreadParameterWithInnerAlias204Response extends H } export declare interface AliasSpreadParameterWithInnerAliasBodyParam { - body?: { + body: { name: string; age: number; }; @@ -79,7 +79,7 @@ export declare interface AliasSpreadParameterWithInnerModel204Response extends H } export declare interface AliasSpreadParameterWithInnerModelBodyParam { - body?: InnerModel; + body: InnerModel; } export declare interface AliasSpreadParameterWithInnerModelHeaderParam { @@ -101,7 +101,7 @@ export declare interface AliasSpreadWithMultipleParameters204Response extends Ht } export declare interface AliasSpreadWithMultipleParametersBodyParam { - body?: { + body: { requiredString: string; optionalInt?: number; requiredIntList: number[]; @@ -135,7 +135,7 @@ export declare interface InnerModel { } export declare interface ModelSpreadAsRequestBody { - put(options?: ModelSpreadAsRequestBodyParameters): StreamableMethod; + put(options: ModelSpreadAsRequestBodyParameters): StreamableMethod; } export declare interface ModelSpreadAsRequestBody204Response extends HttpResponse { @@ -143,7 +143,7 @@ export declare interface ModelSpreadAsRequestBody204Response extends HttpRespons } export declare interface ModelSpreadAsRequestBodyBodyParam { - body?: BodyParameter; + body: BodyParameter; } export declare type ModelSpreadAsRequestBodyParameters = ModelSpreadAsRequestBodyBodyParam & RequestParameters; @@ -177,7 +177,7 @@ export declare interface ModelSpreadCompositeRequestMix204Response extends HttpR } export declare interface ModelSpreadCompositeRequestMixBodyParam { - body?: CompositeRequestMix; + body: CompositeRequestMix; } export declare interface ModelSpreadCompositeRequestMixHeaderParam { diff --git a/packages/typespec-ts/test/integration/generated/payload/multipart/src/index.d.ts b/packages/typespec-ts/test/integration/generated/payload/multipart/src/index.d.ts index d0caf87c8a..508d32106a 100644 --- a/packages/typespec-ts/test/integration/generated/payload/multipart/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/payload/multipart/src/index.d.ts @@ -81,7 +81,7 @@ export declare interface FormDataAnonymousModel204Response extends HttpResponse } export declare interface FormDataAnonymousModelBodyParam { - body?: FormData | Array<{ + body: FormData | Array<{ name: "profileImage"; body: string | Uint8Array | ReadableStream | NodeJS.ReadableStream | File; filename?: string; diff --git a/packages/typespec-ts/test/integration/generated/shared-route/src/index.d.ts b/packages/typespec-ts/test/integration/generated/shared-route/src/index.d.ts index a04404ea92..f70822eb02 100644 --- a/packages/typespec-ts/test/integration/generated/shared-route/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/shared-route/src/index.d.ts @@ -23,7 +23,7 @@ export declare interface ListByResourceGroup200Response extends HttpResponse { } export declare interface ListByResourceGroupBodyParam { - body?: Resource; + body: Resource; } export declare interface ListByResourceGroupDefaultResponse extends HttpResponse { @@ -52,7 +52,7 @@ export declare interface ListBySubscription202Response extends HttpResponse { } export declare interface ListBySubscriptionBodyParam { - body?: Resource; + body: Resource; } export declare interface ListBySubscriptionDefaultResponse extends HttpResponse { @@ -132,7 +132,7 @@ export declare interface ReturnsInt200Response extends HttpResponse { } export declare interface ReturnsIntBodyParam { - body?: Resource; + body: Resource; } export declare type ReturnsIntParameters = ReturnsIntQueryParam & ReturnsIntBodyParam & RequestParameters; @@ -151,7 +151,7 @@ export declare interface ReturnsString200Response extends HttpResponse { } export declare interface ReturnsStringBodyParam { - body?: Resource; + body: Resource; } export declare type ReturnsStringParameters = ReturnsStringQueryParam & ReturnsStringBodyParam & RequestParameters; diff --git a/packages/typespec-ts/test/integration/generated/type/union/src/index.d.ts b/packages/typespec-ts/test/integration/generated/type/union/src/index.d.ts index f66bf30a40..86db2bfebf 100644 --- a/packages/typespec-ts/test/integration/generated/type/union/src/index.d.ts +++ b/packages/typespec-ts/test/integration/generated/type/union/src/index.d.ts @@ -35,7 +35,7 @@ export declare interface EnumsOnlyCasesOutput { export declare interface EnumsOnlyGet { get(options?: EnumsOnlyGetParameters): StreamableMethod; - post(options?: EnumsOnlySendParameters): StreamableMethod; + post(options: EnumsOnlySendParameters): StreamableMethod; } export declare interface EnumsOnlyGet200Response extends HttpResponse { @@ -52,7 +52,7 @@ export declare interface EnumsOnlySend204Response extends HttpResponse { } export declare interface EnumsOnlySendBodyParam { - body?: { + body: { prop: EnumsOnlyCases; }; } @@ -61,7 +61,7 @@ export declare type EnumsOnlySendParameters = EnumsOnlySendBodyParam & RequestPa export declare interface FloatsOnlyGet { get(options?: FloatsOnlyGetParameters): StreamableMethod; - post(options?: FloatsOnlySendParameters): StreamableMethod; + post(options: FloatsOnlySendParameters): StreamableMethod; } export declare interface FloatsOnlyGet200Response extends HttpResponse { @@ -78,7 +78,7 @@ export declare interface FloatsOnlySend204Response extends HttpResponse { } export declare interface FloatsOnlySendBodyParam { - body?: { + body: { prop: 1.1 | 2.2 | 3.3; }; } @@ -87,7 +87,7 @@ export declare type FloatsOnlySendParameters = FloatsOnlySendBodyParam & Request export declare interface IntsOnlyGet { get(options?: IntsOnlyGetParameters): StreamableMethod; - post(options?: IntsOnlySendParameters): StreamableMethod; + post(options: IntsOnlySendParameters): StreamableMethod; } export declare interface IntsOnlyGet200Response extends HttpResponse { @@ -104,7 +104,7 @@ export declare interface IntsOnlySend204Response extends HttpResponse { } export declare interface IntsOnlySendBodyParam { - body?: { + body: { prop: 1 | 2 | 3; }; } @@ -131,7 +131,7 @@ export declare interface MixedLiteralsCasesOutput { export declare interface MixedLiteralsGet { get(options?: MixedLiteralsGetParameters): StreamableMethod; - post(options?: MixedLiteralsSendParameters): StreamableMethod; + post(options: MixedLiteralsSendParameters): StreamableMethod; } export declare interface MixedLiteralsGet200Response extends HttpResponse { @@ -148,7 +148,7 @@ export declare interface MixedLiteralsSend204Response extends HttpResponse { } export declare interface MixedLiteralsSendBodyParam { - body?: { + body: { prop: MixedLiteralsCases; }; } @@ -173,7 +173,7 @@ export declare interface MixedTypesCasesOutput { export declare interface MixedTypesGet { get(options?: MixedTypesGetParameters): StreamableMethod; - post(options?: MixedTypesSendParameters): StreamableMethod; + post(options: MixedTypesSendParameters): StreamableMethod; } export declare interface MixedTypesGet200Response extends HttpResponse { @@ -190,7 +190,7 @@ export declare interface MixedTypesSend204Response extends HttpResponse { } export declare interface MixedTypesSendBodyParam { - body?: { + body: { prop: MixedTypesCases; }; } @@ -199,7 +199,7 @@ export declare type MixedTypesSendParameters = MixedTypesSendBodyParam & Request export declare interface ModelsOnlyGet { get(options?: ModelsOnlyGetParameters): StreamableMethod; - post(options?: ModelsOnlySendParameters): StreamableMethod; + post(options: ModelsOnlySendParameters): StreamableMethod; } export declare interface ModelsOnlyGet200Response extends HttpResponse { @@ -216,7 +216,7 @@ export declare interface ModelsOnlySend204Response extends HttpResponse { } export declare interface ModelsOnlySendBodyParam { - body?: { + body: { prop: Cat | Dog; }; } @@ -248,7 +248,7 @@ export declare interface StringAndArrayCasesOutput { export declare interface StringAndArrayGet { get(options?: StringAndArrayGetParameters): StreamableMethod; - post(options?: StringAndArraySendParameters): StreamableMethod; + post(options: StringAndArraySendParameters): StreamableMethod; } export declare interface StringAndArrayGet200Response extends HttpResponse { @@ -265,7 +265,7 @@ export declare interface StringAndArraySend204Response extends HttpResponse { } export declare interface StringAndArraySendBodyParam { - body?: { + body: { prop: StringAndArrayCases; }; } @@ -274,7 +274,7 @@ export declare type StringAndArraySendParameters = StringAndArraySendBodyParam & export declare interface StringExtensibleGet { get(options?: StringExtensibleGetParameters): StreamableMethod; - post(options?: StringExtensibleSendParameters): StreamableMethod; + post(options: StringExtensibleSendParameters): StreamableMethod; } export declare interface StringExtensibleGet200Response extends HttpResponse { @@ -288,7 +288,7 @@ export declare type StringExtensibleGetParameters = RequestParameters; export declare interface StringExtensibleNamedGet { get(options?: StringExtensibleNamedGetParameters): StreamableMethod; - post(options?: StringExtensibleNamedSendParameters): StreamableMethod; + post(options: StringExtensibleNamedSendParameters): StreamableMethod; } export declare interface StringExtensibleNamedGet200Response extends HttpResponse { @@ -305,7 +305,7 @@ export declare interface StringExtensibleNamedSend204Response extends HttpRespon } export declare interface StringExtensibleNamedSendBodyParam { - body?: { + body: { prop: StringExtensibleNamedUnion; }; } @@ -321,7 +321,7 @@ export declare interface StringExtensibleSend204Response extends HttpResponse { } export declare interface StringExtensibleSendBodyParam { - body?: { + body: { prop: string; }; } @@ -330,7 +330,7 @@ export declare type StringExtensibleSendParameters = StringExtensibleSendBodyPar export declare interface StringsOnlyGet { get(options?: StringsOnlyGetParameters): StreamableMethod; - post(options?: StringsOnlySendParameters): StreamableMethod; + post(options: StringsOnlySendParameters): StreamableMethod; } export declare interface StringsOnlyGet200Response extends HttpResponse { @@ -347,7 +347,7 @@ export declare interface StringsOnlySend204Response extends HttpResponse { } export declare interface StringsOnlySendBodyParam { - body?: { + body: { prop: "a" | "b" | "c"; }; } diff --git a/packages/typespec-ts/test/unit/spreadAndAlias.spec.ts b/packages/typespec-ts/test/unit/spreadAndAlias.spec.ts index 54cfff2b79..c15f70ea25 100644 --- a/packages/typespec-ts/test/unit/spreadAndAlias.spec.ts +++ b/packages/typespec-ts/test/unit/spreadAndAlias.spec.ts @@ -57,7 +57,7 @@ describe("Spread(...) and alias", () => { import { SimpleModel } from "./models.js"; export interface ReadBodyParam { - body?: SimpleModel; + body: SimpleModel; } export type ReadParameters = ReadBodyParam & RequestParameters; @@ -118,7 +118,7 @@ describe("Spread(...) and alias", () => { import { RequestParameters } from "@azure-rest/core-client"; export interface ReadBodyParam { - body?: { name: string; value?: number }; + body: { name: string; value?: number }; } export type ReadParameters = ReadBodyParam & RequestParameters; @@ -147,7 +147,7 @@ describe("Spread(...) and alias", () => { import { User } from "./models.js"; export interface ReadBodyParam { - body?: { user: User }; + body: { user: User }; } export interface ReadQueryParamProperties { @@ -181,7 +181,7 @@ describe("Spread(...) and alias", () => { import { User } from "./models.js"; export interface ReadBodyParam { - body?: { user: User }; + body: { user: User }; } export interface ReadQueryParamProperties {