Open timotheeguerin opened 4 months ago
est: 8
Example what it could look like
function createModelMockApis(route: string, value: any[]): MockApiGetPut {
const url = `/type/array/${route}`;
return {
get: {
url,
method: "get",
request: {},
repsonse: {
status: 200,
body: json(value),
},
},
put: {
url,
method: "put",
request: {
body: json(value),
},
response: {
status: 204,
},
},
};
}
const Int32ValueMock = createModelMockApis("int32", [1, 2]);
Scenarios.Type_Array_Int32Value_get = passOnSuccess(Int32ValueMock.get);
Scenarios.Type_Array_Int32Value_put = passOnSuccess(Int32ValueMock.put);
# Start mock server http://localhost:3000
tsp-spec server start ./node_modules/@typespec/rest-spec
npm run client:test # Run all the emitted client tests - not our problem of what this do
tsp-spec server stop
# upload coverage
npm run start:server:apis # Start the generated server - not our problem of what this do
# Run mock client tests
tsp-spec client run ./node_modules/@typespec/rest-spec
# upload coverage
Scenarios:
As part of having the client emitters as well as trying to reuse the specs for service emitters it would be good to have cadl-ranch be directly into typespec
Currently there is a few packages in cadl-ranch:
cadl-ranch
: Runtimecadl-ranch-expect
: Typespec library adding the custom decoratorscadl-ranch-api
: TS Api to implement the mock apicadl-ranch-dashboard
: Website codecadl-ranch-specs
: The actual specsI think we need could move and rename the following:
cadl-ranch
: Runtimecadl-ranch-expect
: Typespec library adding the custom decoratorscadl-ranch-api
: TS Api to implement the mock apiThen we can migrate the specs expect the azure ones.
The dashboard can remain there for now as it is specific to azure but that will be something that would be very nice to integrate as well
Things to figure out:
@azure-tools/cadl-ranch
@azure-tools/cadl-ranch-expect
@azure-tools/cadl-ranch-api
@azure-tools/cadl-ranch-specs
@typespec/scenario-director
@typespec/scenario-lib
@typespec/scenario-api
@typespec/http-scenarios
@typespec/tsp-cupboard
@typespec/tsp-cupboard-lib
@typespec/tsp-cupboard-api
@typespec/http-tsp-cupboard
@typespec/tsp-recipes
@typespec/tsp-ingredients
@typespec/tsp-recipes-api
@typespec/http-recipes
@typespec/spec-core
@typespec/spec
@typespec/spec
(we could reuse the same lib)@typespec/rest-spec
Other alternatives:
cabinet
instead ofcupboard
for option 2Steps