Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mockapi): dotnet compatibility failure #769

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-dodos-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Fix dotnet compatibility issues in MockApi
6 changes: 6 additions & 0 deletions packages/cadl-ranch-specs/http/type/dictionary/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function createServerTests(uri: string, data: any) {
response: {
status: 204,
},
handler: (req) => {
req.expect.coercedBodyEquals(data);
archerzz marked this conversation as resolved.
Show resolved Hide resolved
return {
status: 204,
};
},
kind: "MockApiDefinition",
}),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { passOnSuccess, ScenarioMockApi, json } from "@azure-tools/cadl-ranch-api";
import { passOnSuccess, ScenarioMockApi, json, MockRequest } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

Expand Down Expand Up @@ -119,6 +119,13 @@ function createServerTests(url: string, value: any) {
response: {
status: 204,
},
handler: (req: MockRequest) => {
const expectedBody = JSON.parse(JSON.stringify(value));
req.expect.coercedBodyEquals(expectedBody);
return {
status: 204,
};
},
kind: "MockApiDefinition",
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ function createServerTests(url: string, value: unknown, patchNullableProperty?:
response: {
status: 204,
},
handler: (req) => {
req.expect.coercedBodyEquals({
requiredProperty: "foo",
nullableProperty: patchNullableProperty || null,
});
return {
status: 204,
};
},
kind: "MockApiDefinition",
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function createServerTests(url: string, value: unknown) {
response: {
status: 204,
},
handler: (req) => {
req.expect.coercedBodyEquals(value);
return {
status: 204,
};
},
kind: "MockApiDefinition",
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function createServerTests(url: string, data: unknown, convertedToFn?: (_: any)
response: {
status: 204,
},
handler: (req) => {
req.expect.coercedBodyEquals(data);
return {
status: 204,
};
},
kind: "MockApiDefinition",
}),
};
Expand Down
Loading