diff --git a/.chronus/changes/fix-example-of-statusCode-2024-5-3-20-58-17.md b/.chronus/changes/fix-example-of-statusCode-2024-5-3-20-58-17.md new file mode 100644 index 0000000000..d09e88744c --- /dev/null +++ b/.chronus/changes/fix-example-of-statusCode-2024-5-3-20-58-17.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: internal +packages: + - "@typespec/http" +--- + +doc: fix incorrect example of `@statusCode` diff --git a/docs/libraries/http/reference/decorators.md b/docs/libraries/http/reference/decorators.md index a9dfefd0dc..444953ea78 100644 --- a/docs/libraries/http/reference/decorators.md +++ b/docs/libraries/http/reference/decorators.md @@ -462,8 +462,13 @@ None #### Examples ```typespec -op read(): {@statusCode: 200, @body pet: Pet} -op create(): {@statusCode: 201 | 202} +op read(): { + @statusCode _: 200; + @body pet: Pet; +}; +op create(): { + @statusCode _: 201 | 202; +}; ``` ### `@useAuth` {#@TypeSpec.Http.useAuth} diff --git a/packages/http/README.md b/packages/http/README.md index 06511ac3d5..2d4e670067 100644 --- a/packages/http/README.md +++ b/packages/http/README.md @@ -509,8 +509,13 @@ None ##### Examples ```typespec -op read(): {@statusCode: 200, @body pet: Pet} -op create(): {@statusCode: 201 | 202} +op read(): { + @statusCode _: 200; + @body pet: Pet; +}; +op create(): { + @statusCode _: 201 | 202; +}; ``` #### `@useAuth` diff --git a/packages/http/generated-defs/TypeSpec.Http.ts b/packages/http/generated-defs/TypeSpec.Http.ts index 6058763fc1..65edeef241 100644 --- a/packages/http/generated-defs/TypeSpec.Http.ts +++ b/packages/http/generated-defs/TypeSpec.Http.ts @@ -12,8 +12,13 @@ import type { * * @example * ```typespec - * op read(): {@statusCode: 200, @body pet: Pet} - * op create(): {@statusCode: 201 | 202} + * op read(): { + * @statusCode _: 200; + * @body pet: Pet; + * }; + * op create(): { + * @statusCode _: 201 | 202; + * }; * ``` */ export type StatusCodeDecorator = (context: DecoratorContext, target: ModelProperty) => void; diff --git a/packages/http/lib/http-decorators.tsp b/packages/http/lib/http-decorators.tsp index f8631f23cb..ed1b8fe879 100644 --- a/packages/http/lib/http-decorators.tsp +++ b/packages/http/lib/http-decorators.tsp @@ -128,8 +128,13 @@ extern dec bodyIgnore(target: ModelProperty); * @example * * ```typespec - * op read(): {@statusCode: 200, @body pet: Pet} - * op create(): {@statusCode: 201 | 202} + * op read(): { + * @statusCode _: 200; + * @body pet: Pet; + * }; + * op create(): { + * @statusCode _: 201 | 202; + * }; * ``` */ extern dec statusCode(target: ModelProperty);