Skip to content
Closed
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
58 changes: 58 additions & 0 deletions packages/http-specs/specs/type/enum/extensible/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ union DaysOfWeekExtensibleEnum {
Sunday: "Sunday",
}

@doc("Service API versions")
union ApiVersionExtensibleEnum {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @iscai-msft was working on a generic special char spec somewehere, I don't think this test belong in this spec, same as we have a SpecialWords one we should have a SpecialChart one which covers those things.

Also api version doesn't make sense here from a core typespec http spec, this is just about having numbers and special chars

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will cover the scenraio in unit test case instead of a new spector case.

string,

@doc("Version 2020-01-01.")
`2020-01-01`: "2020-01-01",

@doc("Version 2021-01-01.")
`2021-01-01`: "2021-01-01",
}

@route("/string")
interface String {
@scenario
Comment thread
msyyc marked this conversation as resolved.
Expand Down Expand Up @@ -79,3 +90,50 @@ interface String {
@body body: DaysOfWeekExtensibleEnum,
): void;
}

@route("/api-version")
interface ApiVersion {
@scenario
@scenarioDoc("Expect to handle a known value. Mock API will return '2020-01-01'")
@get
@route("/known-value")
getKnownValue(): {
@header
contentType: "application/json";

@body body: ApiVersionExtensibleEnum;
};

@scenario
@scenarioDoc("Expect to handle an unknown value. Mock API will return '2022-01-01'")
@get
@route("/unknown-value")
getUnknownValue(): {
@header
contentType: "application/json";

@body body: ApiVersionExtensibleEnum;
};

@scenario
@scenarioDoc("Expect to send a known value. Mock API expects to receive '2020-01-01'")
@put
@route("/known-value")
putKnownValue(
@header
contentType: "application/json",

@body body: ApiVersionExtensibleEnum,
): void;

@scenario
@scenarioDoc("Expect to send an unknown value. Mock API expects to receive '2022-01-01'")
@put
@route("/unknown-value")
putUnknownValue(
@header
contentType: "application/json",

@body body: ApiVersionExtensibleEnum,
): void;
}
18 changes: 18 additions & 0 deletions packages/http-specs/specs/type/enum/extensible/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,21 @@ Scenarios.Type_Enum_Extensible_String_getUnknownValue =
Type_Enum_Extensible_String_UnKnown_Value.get;
Scenarios.Type_Enum_Extensible_String_putUnknownValue =
Type_Enum_Extensible_String_UnKnown_Value.put;

const Type_Enum_Extensible_ApiVersion_KnownValue = createMockServerTests(
`/type/enum/extensible/api-version/known-value`,
"2020-01-01",
);
Scenarios.Type_Enum_Extensible_ApiVersion_getKnownValue =
Type_Enum_Extensible_ApiVersion_KnownValue.get;
Scenarios.Type_Enum_Extensible_ApiVersion_putKnownValue =
Type_Enum_Extensible_ApiVersion_KnownValue.put;

const Type_Enum_Extensible_ApiVersion_UnknownValue = createMockServerTests(
`/type/enum/extensible/api-version/unknown-value`,
"2022-01-01",
);
Scenarios.Type_Enum_Extensible_ApiVersion_getUnknownValue =
Type_Enum_Extensible_ApiVersion_UnknownValue.get;
Scenarios.Type_Enum_Extensible_ApiVersion_putUnknownValue =
Type_Enum_Extensible_ApiVersion_UnknownValue.put;