Skip to content

Success

Base model for all successful responses.

ParameterTypeDescription
statusintegerThe HTTP status code
messagestringThe message to return

A JSON example of this model.

{
"status": 200,
"message": "Success"
}
Version Changes Schema
0.1.0
  • Added Success model
Success.yaml

A 200 response with data.

ParameterTypeDescription
statusintegerThe HTTP status code
messagestringThe message to return
dataanyThe data to return

A JSON example of this model.

{
"status": 200,
"message": "Success",
"data": {
"id": "123",
"name": "Test 1"
}
}

Use the OkT<T> template to define a 200 response with typed data within 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")
@get
op getTest(): OkT<TestModel>;
Version Changes Schema
0.1.0
  • Added Ok model
Ok.yaml

A 201 response with data.

ParameterTypeDescription
statusintegerThe HTTP status code
messagestringThe message to return
dataanyThe data to return

A JSON example of this model.

{
"status": 201,
"message": "Created",
"data": {
"id": "123",
"name": "Test 1"
}
}

Use the CreatedT<T> template to define a 201 response with typed data within an API operation:

import "@common-grants/core";
import "@typespec/http";
using TypeSpec.Http;
using CommonGrants.Responses;
model TestModel {
id: string;
name: string;
}
@summary("Create test")
@doc("Create a test model")
@post
op createTest(@body body: TestModel): CreatedT<TestModel>;
Version Changes Schema
0.1.0
  • Added Created model
Created.yaml