Skip to content

Instantly share code, notes, and snippets.

@sashalikesplanes
Created July 17, 2024 12:41
Show Gist options
  • Save sashalikesplanes/1bb01a27d9063679fd4a79d684f451e0 to your computer and use it in GitHub Desktop.
Save sashalikesplanes/1bb01a27d9063679fd4a79d684f451e0 to your computer and use it in GitHub Desktop.
{
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
"title": "API Example",
"definitions": {
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Unique identifier for the user"
},
"name": {
"type": "string",
"description": "Name of the user"
},
"email": {
"type": "string",
"description": "Email address of the user"
}
},
"links": [
{
"rel": "self",
"href": "/users/{id}",
"targetSchema": {
"$ref": "#/definitions/User"
}
}
]
},
"UserRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"description": "Unique identifier for the user, maps to 'id' in User"
},
"userName": {
"type": "string",
"description": "Name of the user, maps to 'name' in User"
},
"userEmail": {
"type": "string",
"description": "Email address of the user, maps to 'email' in User"
}
},
"required": ["userId", "userName", "userEmail"],
"links": [
{
"rel": "create",
"href": "/users",
"method": "POST",
"targetSchema": {
"$ref": "#/definitions/User"
},
"mapping": {
"id": "userId",
"name": "userName",
"email": "userEmail"
}
}
]
},
"UserResponse": {
"allOf": [
{
"$ref": "#/definitions/User"
}
]
}
},
"links": [
{
"rel": "self",
"href": "/users/{id}",
"targetSchema": {
"$ref": "#/definitions/User"
}
},
{
"rel": "create",
"href": "/users",
"method": "POST",
"schema": {
"$ref": "#/definitions/UserRequest"
},
"targetSchema": {
"$ref": "#/definitions/UserResponse"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment