Success
Success
Section titled “Success”A 200 response with data.
| Parameter | Type | Description |
|---|---|---|
| status | integer | The HTTP status code |
| message | string | The message to return |
| data | any | The data to return |
Formats
Section titled “Formats”A JSON example of this model.
{ "status": 200, "message": "Success"}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: Success.yamltype: objectproperties: status: type: integer minimum: -2147483648 maximum: 2147483647 examples: - 200 message: type: string examples: - Successrequired: - status - messageunevaluatedProperties: not: {}The TypeSpec code for this model.
model Success { @example(200) status: int32;
@example("Success") message: string;}The Python code for this model.
class Success(DefaultResponse): """Default success response."""
status: int = Field( default=200, description="The HTTP status code", examples=[200], ) message: str = Field( default="Success", description="The message", examples=["Success"], )The TypeScript code for this model.
export const SuccessSchema = z.object({ /** HTTP status code */ status: z.number().int(),
/** Success message */ message: z.string(),});Changelog
Section titled “Changelog”| Version | Changes | Schema |
|---|---|---|
| 0.1.0 |
| Success.yaml |
Here’s an example of how to use the Ok response within a an API operation:
import "@common-grants/core";import "@typespec/http";
using TypeSpec.Http;using CommonGrants.Responses;
model TestModel { id: string; name: string;}
@summary("Get test")@doc("Get a test model")@getop getTest(): Ok<TestModel>;