From 980a1e654acbc69d9d5082e537aa89b162c074e7 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:49:37 +0800 Subject: [PATCH 1/7] Add tests for literal types --- .changeset/bright-houses-turn.md | 5 + .../cadl-ranch-specs/cadl-ranch-summary.md | 420 ++++++++++++++++++ .../http/payload/content-negotiation/main.tsp | 2 +- .../http/type/property/optionality/main.tsp | 49 ++ .../http/type/property/optionality/mockapi.ts | 42 ++ .../http/type/property/value-types/main.tsp | 42 ++ .../http/type/property/value-types/mockapi.ts | 28 ++ 7 files changed, 587 insertions(+), 1 deletion(-) create mode 100644 .changeset/bright-houses-turn.md diff --git a/.changeset/bright-houses-turn.md b/.changeset/bright-houses-turn.md new file mode 100644 index 000000000..35125b0f3 --- /dev/null +++ b/.changeset/bright-houses-turn.md @@ -0,0 +1,5 @@ +--- +"@azure-tools/cadl-ranch-specs": patch +--- + +Add tests for literal types diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index a0107afbf..75ba4f6a4 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -3143,6 +3143,46 @@ Expected request body: { "requiredProperty": "foo", "nullableProperty": null } ``` +### Type_Property_Optional_BooleanLiteral_getAll + +- Endpoint: `get /type/property/optional/boolean/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_BooleanLiteral_getDefault + +- Endpoint: `get /type/property/optional/boolean/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_BooleanLiteral_putAll + +- Endpoint: `put /type/property/optional/boolean/literal/all` + +Expected request body: + +```json +{ "property": true } +``` + +### Type_Property_Optional_BooleanLiteral_putDefault + +- Endpoint: `put /type/property/optional/boolean/literal/default` + +Expected request body: + +```json +{} +``` + ### Type_Property_Optional_Bytes_getAll - Endpoint: `get /type/property/optional/bytes/all` @@ -3343,6 +3383,86 @@ Expected request body: {} ``` +### Type_Property_Optional_FloatLiteral_getAll + +- Endpoint: `get /type/property/optional/float/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_FloatLiteral_getDefault + +- Endpoint: `get /type/property/optional/float/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_FloatLiteral_putAll + +- Endpoint: `put /type/property/optional/float/literal/all` + +Expected request body: + +```json +{ "property": 1.2 } +``` + +### Type_Property_Optional_FloatLiteral_putDefault + +- Endpoint: `put /type/property/optional/float/literal/default` + +Expected request body: + +```json +{} +``` + +### Type_Property_Optional_IntLiteral_getAll + +- Endpoint: `get /type/property/optional/int/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_IntLiteral_getDefault + +- Endpoint: `get /type/property/optional/int/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_IntLiteral_putAll + +- Endpoint: `put /type/property/optional/int/literal/all` + +Expected request body: + +```json +{ "property": 1 } +``` + +### Type_Property_Optional_IntLiteral_putDefault + +- Endpoint: `put /type/property/optional/int/literal/default` + +Expected request body: + +```json +{} +``` + ### Type_Property_Optional_RequiredAndOptional_getAll - Endpoint: `get /type/property/optional/requiredAndOptional/all` @@ -3423,6 +3543,166 @@ Expected request body: {} ``` +### Type_Property_Optional_StringLiteral_getAll + +- Endpoint: `get /type/property/optional/string/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_StringLiteral_getDefault + +- Endpoint: `get /type/property/optional/string/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_StringLiteral_putAll + +- Endpoint: `put /type/property/optional/string/literal/all` + +Expected request body: + +```json +{"property": hello} +``` + +### Type_Property_Optional_StringLiteral_putDefault + +- Endpoint: `put /type/property/optional/string/literal/default` + +Expected request body: + +```json +{} +``` + +### Type_Property_Optional_UnionFloatLiteral_getAll + +- Endpoint: `get /type/property/optional/union/float/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_UnionFloatLiteral_getDefault + +- Endpoint: `get /type/property/optional/union/float/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_UnionFloatLiteral_putAll + +- Endpoint: `put /type/property/optional/union/float/literal/all` + +Expected request body: + +```json +{ "property": 2.3 } +``` + +### Type_Property_Optional_UnionFloatLiteral_putDefault + +- Endpoint: `put /type/property/optional/union/float/literal/default` + +Expected request body: + +```json +{} +``` + +### Type_Property_Optional_UnionIntLiteral_getAll + +- Endpoint: `get /type/property/optional/union/int/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_UnionIntLiteral_getDefault + +- Endpoint: `get /type/property/optional/union/int/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_UnionIntLiteral_putAll + +- Endpoint: `put /type/property/optional/union/int/literal/all` + +Expected request body: + +```json +{ "property": 2 } +``` + +### Type_Property_Optional_UnionIntLiteral_putDefault + +- Endpoint: `put /type/property/optional/union/int/literal/default` + +Expected request body: + +```json +{} +``` + +### Type_Property_Optional_UnionStringLiteral_getAll + +- Endpoint: `get /type/property/optional/union/string/literal/all` + +Expected response body: + +```json +{"property": doc} +``` + +### Type_Property_Optional_UnionStringLiteral_getDefault + +- Endpoint: `get /type/property/optional/union/string/literal/default` + +Expected response body: + +```json +{} +``` + +### Type_Property_Optional_UnionStringLiteral_putAll + +- Endpoint: `put /type/property/optional/union/string/literal/all` + +Expected request body: + +```json +{"property": world} +``` + +### Type_Property_Optional_UnionStringLiteral_putDefault + +- Endpoint: `put /type/property/optional/union/string/literal/default` + +Expected request body: + +```json +{} +``` + ### Type_Property_ValueTypes_Boolean_get - Endpoint: `get /type/property/value-types/boolean` @@ -3443,6 +3723,26 @@ Expected input body: { "property": true } ``` +### Type_Property_ValueTypes_BooleanLiteral_get + +- Endpoint: `get /type/property/value-types/boolean/literal` + +Expected response body: + +```json +{ "property": true } +``` + +### Type_Property_ValueTypes_BooleanLiteral_put + +- Endpoint: `put /type/property/value-types/boolean/literal` + +Expected input body: + +```json +{ "property": true } +``` + ### Type_Property_ValueTypes_Bytes_get - Endpoint: `get /type/property/value-types/bytes` @@ -3643,6 +3943,26 @@ Expected input body: { "property": 42.42 } ``` +### Type_Property_ValueTypes_FloatLiteral_get + +- Endpoint: `get /type/property/value-types/float/literal` + +Expected response body: + +```json +{ "property": 42.42 } +``` + +### Type_Property_ValueTypes_FloatLiteral_put + +- Endpoint: `put /type/property/value-types/float/literal` + +Expected input body: + +```json +{ "property": 42.42 } +``` + ### Type_Property_ValueTypes_Int_get - Endpoint: `get /type/property/value-types/int` @@ -3663,6 +3983,26 @@ Expected input body: { "property": 42 } ``` +### Type_Property_ValueTypes_IntLiteral_get + +- Endpoint: `get /type/property/value-types/int/literal` + +Expected response body: + +```json +{ "property": 42 } +``` + +### Type_Property_ValueTypes_IntLiteral_put + +- Endpoint: `put /type/property/value-types/int/literal` + +Expected input body: + +```json +{ "property": 42 } +``` + ### Type_Property_ValueTypes_Model_get - Endpoint: `get /type/property/value-types/model` @@ -3723,6 +4063,86 @@ Expected input body: {"property": hello} ``` +### Type_Property_ValueTypes_StringLiteral_get + +- Endpoint: `get /type/property/value-types/string/literal` + +Expected response body: + +```json +{"property": hello} +``` + +### Type_Property_ValueTypes_StringLiteral_put + +- Endpoint: `put /type/property/value-types/string/literal` + +Expected input body: + +```json +{"property": hello} +``` + +### Type_Property_ValueTypes_UnionFloatLiteral_get + +- Endpoint: `get /type/property/value-types/union/float/literal` + +Expected response body: + +```json +{ "property": 43.43 } +``` + +### Type_Property_ValueTypes_UnionFloatLiteral_put + +- Endpoint: `put /type/property/value-types/union/float/literal` + +Expected input body: + +```json +{ "property": 43.43 } +``` + +### Type_Property_ValueTypes_UnionIntLiteral_get + +- Endpoint: `get /type/property/value-types/union/int/literal` + +Expected response body: + +```json +{ "property": 42 } +``` + +### Type_Property_ValueTypes_UnionIntLiteral_put + +- Endpoint: `put /type/property/value-types/union/int/literal` + +Expected input body: + +```json +{ "property": 42 } +``` + +### Type_Property_ValueTypes_UnionStringLiteral_get + +- Endpoint: `get /type/property/value-types/union/string/literal` + +Expected response body: + +```json +{"property": world} +``` + +### Type_Property_ValueTypes_UnionStringLiteral_put + +- Endpoint: `put /type/property/value-types/union/string/literal` + +Expected input body: + +```json +{"property": world} +``` + ### Type_Property_ValueTypes_UnknownArray_get - Endpoint: `get /type/property/value-types/unknown/array` diff --git a/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp b/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp index 4077af984..1f0c94817 100644 --- a/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp +++ b/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp @@ -54,7 +54,7 @@ namespace DifferentBody { model PngImageAsJson { @header contentType: "image/jpeg"; - content: bytes; + content: string; } @sharedRoute diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp index f389dca1d..291c46fe4 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp @@ -128,6 +128,55 @@ model CollectionsModelProperty is ModelTemplate; interface CollectionsModel extends OperationsTemplate {} +// Model with optional string literal property +@doc("Model with string literal property") +model StringLiteralProperty is ModelTemplate<"hello">; +@route("/string/literal") +@operationGroup +interface StringLiteral extends OperationsTemplate {} + +// Model with optional int literal property +@doc("Model with int literal property") +model IntLiteralProperty is ModelTemplate<1>; +@route("/int/literal") +@operationGroup +interface IntLiteral extends OperationsTemplate {} + +// Model with optional float literal property +@doc("Model with float literal property") +model FloatLiteralProperty is ModelTemplate<1.2>; +@route("/float/literal") +@operationGroup +interface FloatLiteral extends OperationsTemplate {} + +// Model with optional boolean literal property +@doc("Model with boolean literal property") +model BooleanLiteralProperty is ModelTemplate; +@route("/boolean/literal") +@operationGroup +interface BooleanLiteral extends OperationsTemplate {} + +// Model with union of string literal property +@doc("Model with union of string literal property") +model UnionStringLiteralProperty is ModelTemplate<"hello" | "world">; +@route("/union/string/literal") +@operationGroup +interface UnionStringLiteral extends OperationsTemplate {} + +// Model with union of int literal property +@doc("Model with union of int literal property") +model UnionIntLiteralProperty is ModelTemplate<1 | 2>; +@route("/union/int/literal") +@operationGroup +interface UnionIntLiteral extends OperationsTemplate {} + +// Model with union of float literal property +@doc("Model with union of float literal property") +model UnionFloatLiteralProperty is ModelTemplate<1.2 | 2.3>; +@route("/union/float/literal") +@operationGroup +interface UnionFloatLiteral extends OperationsTemplate {} + @doc("Model with required and optional properties") model RequiredAndOptionalProperty { @doc("optional string property") diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/mockapi.ts b/packages/cadl-ranch-specs/http/type/property/optionality/mockapi.ts index 71baa381b..89076301b 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/mockapi.ts +++ b/packages/cadl-ranch-specs/http/type/property/optionality/mockapi.ts @@ -89,6 +89,48 @@ Scenarios.Type_Property_Optional_CollectionsModel_getDefault = passOnSuccess(col Scenarios.Type_Property_Optional_CollectionsModel_putAll = passOnSuccess(collectionsModelMock.putAll); Scenarios.Type_Property_Optional_CollectionsModel_putDefault = passOnSuccess(collectionsModelMock.putDefault); +const stringLiteralMock = createMockApis("string/literal", "hello"); +Scenarios.Type_Property_Optional_StringLiteral_getAll = passOnSuccess(stringLiteralMock.getAll); +Scenarios.Type_Property_Optional_StringLiteral_getDefault = passOnSuccess(stringLiteralMock.getDefault); +Scenarios.Type_Property_Optional_StringLiteral_putAll = passOnSuccess(stringLiteralMock.putAll); +Scenarios.Type_Property_Optional_StringLiteral_putDefault = passOnSuccess(stringLiteralMock.putDefault); + +const intLiteralMock = createMockApis("int/literal", 1); +Scenarios.Type_Property_Optional_IntLiteral_getAll = passOnSuccess(intLiteralMock.getAll); +Scenarios.Type_Property_Optional_IntLiteral_getDefault = passOnSuccess(intLiteralMock.getDefault); +Scenarios.Type_Property_Optional_IntLiteral_putAll = passOnSuccess(intLiteralMock.putAll); +Scenarios.Type_Property_Optional_IntLiteral_putDefault = passOnSuccess(intLiteralMock.putDefault); + +const floatLiteralMock = createMockApis("float/literal", 1.2); +Scenarios.Type_Property_Optional_FloatLiteral_getAll = passOnSuccess(floatLiteralMock.getAll); +Scenarios.Type_Property_Optional_FloatLiteral_getDefault = passOnSuccess(floatLiteralMock.getDefault); +Scenarios.Type_Property_Optional_FloatLiteral_putAll = passOnSuccess(floatLiteralMock.putAll); +Scenarios.Type_Property_Optional_FloatLiteral_putDefault = passOnSuccess(floatLiteralMock.putDefault); + +const booleanLiteralMock = createMockApis("boolean/literal", true); +Scenarios.Type_Property_Optional_BooleanLiteral_getAll = passOnSuccess(booleanLiteralMock.getAll); +Scenarios.Type_Property_Optional_BooleanLiteral_getDefault = passOnSuccess(booleanLiteralMock.getDefault); +Scenarios.Type_Property_Optional_BooleanLiteral_putAll = passOnSuccess(booleanLiteralMock.putAll); +Scenarios.Type_Property_Optional_BooleanLiteral_putDefault = passOnSuccess(booleanLiteralMock.putDefault); + +const unionStringLiteralMock = createMockApis("union/string/literal", "world"); +Scenarios.Type_Property_Optional_UnionStringLiteral_getAll = passOnSuccess(unionStringLiteralMock.getAll); +Scenarios.Type_Property_Optional_UnionStringLiteral_getDefault = passOnSuccess(unionStringLiteralMock.getDefault); +Scenarios.Type_Property_Optional_UnionStringLiteral_putAll = passOnSuccess(unionStringLiteralMock.putAll); +Scenarios.Type_Property_Optional_UnionStringLiteral_putDefault = passOnSuccess(unionStringLiteralMock.putDefault); + +const unionIntLiteralMock = createMockApis("union/int/literal", 2); +Scenarios.Type_Property_Optional_UnionIntLiteral_getAll = passOnSuccess(unionIntLiteralMock.getAll); +Scenarios.Type_Property_Optional_UnionIntLiteral_getDefault = passOnSuccess(unionIntLiteralMock.getDefault); +Scenarios.Type_Property_Optional_UnionIntLiteral_putAll = passOnSuccess(unionIntLiteralMock.putAll); +Scenarios.Type_Property_Optional_UnionIntLiteral_putDefault = passOnSuccess(unionIntLiteralMock.putDefault); + +const unionFloatLiteralMock = createMockApis("union/float/literal", 2.3); +Scenarios.Type_Property_Optional_UnionFloatLiteral_getAll = passOnSuccess(unionFloatLiteralMock.getAll); +Scenarios.Type_Property_Optional_UnionFloatLiteral_getDefault = passOnSuccess(unionFloatLiteralMock.getDefault); +Scenarios.Type_Property_Optional_UnionFloatLiteral_putAll = passOnSuccess(unionFloatLiteralMock.putAll); +Scenarios.Type_Property_Optional_UnionFloatLiteral_putDefault = passOnSuccess(unionFloatLiteralMock.putDefault); + // TEST REQUIRED AND OPTIONAL PROPERTIES const requiredAndOptionalBaseUrl = `/type/property/optional/requiredAndOptional`; diff --git a/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp b/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp index 976ba57cf..3a4c84ed4 100644 --- a/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp @@ -211,3 +211,45 @@ model UnknownArrayProperty is ModelTemplate; @route("/unknown/array") @operationGroup interface UnknownArray extends ModelOperations {} + +@doc("Model with a string literal property.") +model StringLiteralProperty is ModelTemplate<"hello">; +@route("/string/literal") +@operationGroup +interface StringLiteral extends ModelOperations {} + +@doc("Model with a int literal property.") +model IntLiteralProperty is ModelTemplate<42>; +@route("/int/literal") +@operationGroup +interface IntLiteral extends ModelOperations {} + +@doc("Model with a float literal property.") +model FloatLiteralProperty is ModelTemplate<42.42>; +@route("/float/literal") +@operationGroup +interface FloatLiteral extends ModelOperations {} + +@doc("Model with a boolean literal property.") +model BooleanLiteralProperty is ModelTemplate; +@route("/boolean/literal") +@operationGroup +interface BooleanLiteral extends ModelOperations {} + +@doc("Model with a union of string literal as property.") +model UnionStringLiteralProperty is ModelTemplate<"hello" | "world">; +@route("/union/string/literal") +@operationGroup +interface UnionStringLiteral extends ModelOperations {} + +@doc("Model with a union of int literal as property.") +model UnionIntLiteralProperty is ModelTemplate<42 | 43>; +@route("/union/int/literal") +@operationGroup +interface UnionIntLiteral extends ModelOperations {} + +@doc("Model with a union of float literal as property.") +model UnionFloatLiteralProperty is ModelTemplate<42.42 | 43.43>; +@route("/union/float/literal") +@operationGroup +interface UnionFloatLiteral extends ModelOperations {} diff --git a/packages/cadl-ranch-specs/http/type/property/value-types/mockapi.ts b/packages/cadl-ranch-specs/http/type/property/value-types/mockapi.ts index c8950e7bd..77fa47d5b 100644 --- a/packages/cadl-ranch-specs/http/type/property/value-types/mockapi.ts +++ b/packages/cadl-ranch-specs/http/type/property/value-types/mockapi.ts @@ -107,3 +107,31 @@ Scenarios.Type_Property_ValueTypes_UnknownDict_put = passOnSuccess(unknownDictMo const unknownArrayMock = createMockApis("unknown/array", ["hello", "world"]); Scenarios.Type_Property_ValueTypes_UnknownArray_get = passOnSuccess(unknownArrayMock.get); Scenarios.Type_Property_ValueTypes_UnknownArray_put = passOnSuccess(unknownArrayMock.put); + +const stringLiteralMock = createMockApis("string/literal", "hello"); +Scenarios.Type_Property_ValueTypes_StringLiteral_get = passOnSuccess(stringLiteralMock.get); +Scenarios.Type_Property_ValueTypes_StringLiteral_put = passOnSuccess(stringLiteralMock.put); + +const intLiteralMock = createMockApis("int/literal", 42); +Scenarios.Type_Property_ValueTypes_IntLiteral_get = passOnSuccess(intLiteralMock.get); +Scenarios.Type_Property_ValueTypes_IntLiteral_put = passOnSuccess(intLiteralMock.put); + +const floatLiteralMock = createMockApis("float/literal", 42.42); +Scenarios.Type_Property_ValueTypes_FloatLiteral_get = passOnSuccess(floatLiteralMock.get); +Scenarios.Type_Property_ValueTypes_FloatLiteral_put = passOnSuccess(floatLiteralMock.put); + +const booleanLiteralMock = createMockApis("boolean/literal", true); +Scenarios.Type_Property_ValueTypes_BooleanLiteral_get = passOnSuccess(booleanLiteralMock.get); +Scenarios.Type_Property_ValueTypes_BooleanLiteral_put = passOnSuccess(booleanLiteralMock.put); + +const unionStringLiteralMock = createMockApis("union/string/literal", "world"); +Scenarios.Type_Property_ValueTypes_UnionStringLiteral_get = passOnSuccess(unionStringLiteralMock.get); +Scenarios.Type_Property_ValueTypes_UnionStringLiteral_put = passOnSuccess(unionStringLiteralMock.put); + +const unionIntLiteralMock = createMockApis("union/int/literal", 42); +Scenarios.Type_Property_ValueTypes_UnionIntLiteral_get = passOnSuccess(unionIntLiteralMock.get); +Scenarios.Type_Property_ValueTypes_UnionIntLiteral_put = passOnSuccess(unionIntLiteralMock.put); + +const unionFloatLiteralMock = createMockApis("union/float/literal", 43.43); +Scenarios.Type_Property_ValueTypes_UnionFloatLiteral_get = passOnSuccess(unionFloatLiteralMock.get); +Scenarios.Type_Property_ValueTypes_UnionFloatLiteral_put = passOnSuccess(unionFloatLiteralMock.put); From 50483364307268ccde3a95687be4c63cf5e69388 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:01:50 +0800 Subject: [PATCH 2/7] update --- .../cadl-ranch-specs/http/payload/content-negotiation/main.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp b/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp index 1f0c94817..4077af984 100644 --- a/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp +++ b/packages/cadl-ranch-specs/http/payload/content-negotiation/main.tsp @@ -54,7 +54,7 @@ namespace DifferentBody { model PngImageAsJson { @header contentType: "image/jpeg"; - content: string; + content: bytes; } @sharedRoute From 2c1be77ba8531a0e7cf8cc6625fb7b976715926b Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:44:55 +0800 Subject: [PATCH 3/7] update --- packages/cadl-ranch-specs/cadl-ranch-summary.md | 2 +- .../cadl-ranch-specs/http/type/property/optionality/main.tsp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index b71b52355..c2a7a84ff 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -4446,7 +4446,7 @@ Expected response body: Expected request body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_Optional_StringLiteral_putDefault diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp index 291c46fe4..aa7dd41ae 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp @@ -133,7 +133,7 @@ interface CollectionsModel model StringLiteralProperty is ModelTemplate<"hello">; @route("/string/literal") @operationGroup -interface StringLiteral extends OperationsTemplate {} +interface StringLiteral extends OperationsTemplate {} // Model with optional int literal property @doc("Model with int literal property") From c12996cc011990412cca41a830065350dbca3056 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Thu, 26 Oct 2023 15:57:30 +0800 Subject: [PATCH 4/7] update --- packages/cadl-ranch-specs/cadl-ranch-summary.md | 10 +++++----- .../http/type/property/optionality/main.tsp | 2 +- .../http/type/property/value-types/main.tsp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index c2a7a84ff..a7551edfd 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -4566,7 +4566,7 @@ Expected response body: Expected request body: ```json -{"property": world} +{ "property": "world" } ``` ### Type_Property_Optional_UnionStringLiteral_putDefault @@ -4946,7 +4946,7 @@ Expected input body: Expected response body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_ValueTypes_StringLiteral_put @@ -4956,7 +4956,7 @@ Expected response body: Expected input body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_ValueTypes_UnionFloatLiteral_get @@ -5006,7 +5006,7 @@ Expected input body: Expected response body: ```json -{"property": world} +{ "property": "world" } ``` ### Type_Property_ValueTypes_UnionStringLiteral_put @@ -5016,7 +5016,7 @@ Expected response body: Expected input body: ```json -{"property": world} +{ "property": "world" } ``` ### Type_Property_ValueTypes_UnknownArray_get diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp index aa7dd41ae..590817192 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp @@ -161,7 +161,7 @@ interface BooleanLiteral extends OperationsTemplate; @route("/union/string/literal") @operationGroup -interface UnionStringLiteral extends OperationsTemplate {} +interface UnionStringLiteral extends OperationsTemplate {} // Model with union of int literal property @doc("Model with union of int literal property") diff --git a/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp b/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp index 3a4c84ed4..24ff94364 100644 --- a/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp @@ -216,7 +216,7 @@ interface UnknownArray extends ModelOperations; @route("/string/literal") @operationGroup -interface StringLiteral extends ModelOperations {} +interface StringLiteral extends ModelOperations {} @doc("Model with a int literal property.") model IntLiteralProperty is ModelTemplate<42>; @@ -240,7 +240,7 @@ interface BooleanLiteral extends ModelOperations model UnionStringLiteralProperty is ModelTemplate<"hello" | "world">; @route("/union/string/literal") @operationGroup -interface UnionStringLiteral extends ModelOperations {} +interface UnionStringLiteral extends ModelOperations {} @doc("Model with a union of int literal as property.") model UnionIntLiteralProperty is ModelTemplate<42 | 43>; From 056c8adca5b146fc2b1c2400736c0e722a9fd1c0 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:49:08 +0800 Subject: [PATCH 5/7] update --- .../cadl-ranch-specs/cadl-ranch-summary.md | 26 +++++++++---------- .../http/type/property/optionality/main.tsp | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index a7551edfd..9da85f2c5 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -4026,7 +4026,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": true } ``` ### Type_Property_Optional_BooleanLiteral_getDefault @@ -4066,7 +4066,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{"property": aGVsbG8sIHdvcmxkIQ==} ``` ### Type_Property_Optional_Bytes_getDefault @@ -4106,7 +4106,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{"property": [aGVsbG8sIHdvcmxkIQ==, aGVsbG8sIHdvcmxkIQ==]} ``` ### Type_Property_Optional_CollectionsByte_getDefault @@ -4146,7 +4146,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": [{ "property": "hello" }, { "property": "world" }] } ``` ### Type_Property_Optional_CollectionsModel_getDefault @@ -4186,7 +4186,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{"property": 2022-08-26T18:38:00Z} ``` ### Type_Property_Optional_Datetime_getDefault @@ -4226,7 +4226,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{"property": P123DT22H14M12.011S} ``` ### Type_Property_Optional_Duration_getDefault @@ -4266,7 +4266,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": 1.2 } ``` ### Type_Property_Optional_FloatLiteral_getDefault @@ -4306,7 +4306,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": 1 } ``` ### Type_Property_Optional_IntLiteral_getDefault @@ -4386,7 +4386,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{"property": hello} ``` ### Type_Property_Optional_String_getDefault @@ -4426,7 +4426,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": "hello" } ``` ### Type_Property_Optional_StringLiteral_getDefault @@ -4466,7 +4466,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": 2.3 } ``` ### Type_Property_Optional_UnionFloatLiteral_getDefault @@ -4506,7 +4506,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": 2 } ``` ### Type_Property_Optional_UnionIntLiteral_getDefault @@ -4546,7 +4546,7 @@ Expected request body: Expected response body: ```json -{"property": doc} +{ "property": "world" } ``` ### Type_Property_Optional_UnionStringLiteral_getDefault diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp index 590817192..f39d60369 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp @@ -23,7 +23,7 @@ interface OperationsTemplate Date: Fri, 27 Oct 2023 10:52:02 +0800 Subject: [PATCH 6/7] update --- packages/cadl-ranch-specs/cadl-ranch-summary.md | 8 ++++---- .../http/type/property/optionality/main.tsp | 2 +- .../http/type/property/value-types/main.tsp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 9da85f2c5..4dca3a326 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -4386,7 +4386,7 @@ Expected request body: Expected response body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_Optional_String_getDefault @@ -4406,7 +4406,7 @@ Expected response body: Expected request body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_Optional_String_putDefault @@ -4926,7 +4926,7 @@ Expected input body: Expected response body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_ValueTypes_String_put @@ -4936,7 +4936,7 @@ Expected response body: Expected input body: ```json -{"property": hello} +{ "property": "hello" } ``` ### Type_Property_ValueTypes_StringLiteral_get diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp index f39d60369..4b384b8d6 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp @@ -90,7 +90,7 @@ interface OperationsTemplate; @route("/string") @operationGroup -interface String extends OperationsTemplate {} +interface String extends OperationsTemplate {} // Model with optional bytes property model BytesProperty is ModelTemplate; diff --git a/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp b/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp index 24ff94364..e98f57300 100644 --- a/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/value-types/main.tsp @@ -66,7 +66,7 @@ interface Boolean extends ModelOperations {} model StringProperty is ModelTemplate; @route("/string") @operationGroup -interface String extends ModelOperations {} +interface String extends ModelOperations {} // Test a model with a bytes property @doc("Model with a bytes property") From 409a2e777aba2632cd0411860072c2c7e14742f2 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Fri, 27 Oct 2023 16:05:16 +0800 Subject: [PATCH 7/7] update --- packages/cadl-ranch-specs/cadl-ranch-summary.md | 16 ++++++++-------- .../http/type/property/optionality/main.tsp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 4dca3a326..c6843e0d1 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -4066,7 +4066,7 @@ Expected request body: Expected response body: ```json -{"property": aGVsbG8sIHdvcmxkIQ==} +{ "property": "aGVsbG8sIHdvcmxkIQ==" } ``` ### Type_Property_Optional_Bytes_getDefault @@ -4086,7 +4086,7 @@ Expected response body: Expected request body: ```json -{"property": aGVsbG8sIHdvcmxkIQ==} +{ "property": "aGVsbG8sIHdvcmxkIQ==" } ``` ### Type_Property_Optional_Bytes_putDefault @@ -4106,7 +4106,7 @@ Expected request body: Expected response body: ```json -{"property": [aGVsbG8sIHdvcmxkIQ==, aGVsbG8sIHdvcmxkIQ==]} +{ "property": ["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="] } ``` ### Type_Property_Optional_CollectionsByte_getDefault @@ -4126,7 +4126,7 @@ Expected response body: Expected request body: ```json -{"property": [aGVsbG8sIHdvcmxkIQ==, aGVsbG8sIHdvcmxkIQ==]} +{ "property": ["aGVsbG8sIHdvcmxkIQ==", "aGVsbG8sIHdvcmxkIQ=="] } ``` ### Type_Property_Optional_CollectionsByte_putDefault @@ -4186,7 +4186,7 @@ Expected request body: Expected response body: ```json -{"property": 2022-08-26T18:38:00Z} +{ "property": "2022-08-26T18:38:00Z" } ``` ### Type_Property_Optional_Datetime_getDefault @@ -4206,7 +4206,7 @@ Expected response body: Expected request body: ```json -{"property": 2022-08-26T18:38:00Z} +{ "property": "2022-08-26T18:38:00Z" } ``` ### Type_Property_Optional_Datetime_putDefault @@ -4226,7 +4226,7 @@ Expected request body: Expected response body: ```json -{"property": P123DT22H14M12.011S} +{ "property": "P123DT22H14M12.011S" } ``` ### Type_Property_Optional_Duration_getDefault @@ -4246,7 +4246,7 @@ Expected response body: Expected request body: ```json -{"property": P123DT22H14M12.011S} +{ "property": "P123DT22H14M12.011S" } ``` ### Type_Property_Optional_Duration_putDefault diff --git a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp index 4b384b8d6..49db0ee29 100644 --- a/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp +++ b/packages/cadl-ranch-specs/http/type/property/optionality/main.tsp @@ -96,21 +96,21 @@ interface String extends OperationsTemplate {} model BytesProperty is ModelTemplate; @route("/bytes") @operationGroup -interface Bytes extends OperationsTemplate {} +interface Bytes extends OperationsTemplate {} // Model with optional datetime property @doc("Model with a datetime property") model DatetimeProperty is ModelTemplate; @route("/datetime") @operationGroup -interface Datetime extends OperationsTemplate {} +interface Datetime extends OperationsTemplate {} // Model with optional duration property @doc("Model with a duration property") model DurationProperty is ModelTemplate; @route("/duration") @operationGroup -interface Duration extends OperationsTemplate {} +interface Duration extends OperationsTemplate {} // Model with optional collection bytes property @doc("Model with collection bytes properties") @@ -118,7 +118,7 @@ model CollectionsByteProperty is ModelTemplate; @route("/collections/bytes") @operationGroup interface CollectionsByte - extends OperationsTemplate {} + extends OperationsTemplate {} // Model with optional collection models property @doc("Model with collection models properties")