Skip to content

Commit

Permalink
Add misc schema for testing required field
Browse files Browse the repository at this point in the history
  • Loading branch information
Nymphium committed Apr 30, 2024
1 parent a345403 commit 559e545
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 0 deletions.
73 changes: 73 additions & 0 deletions _example/doc/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,76 @@
"detail"
]
},
"misc": {
"$schema": "http://json-schema.org/draft-04/hyper-schema",
"title": "Misc",
"description": "Misc",
"stability": "prototype",
"strictProperties": true,
"type": [
"object"
],
"definitions": {
"id": {
"description": "misc id",
"example": "ec0a1edc-062e-11e7-8b1e-040ccee2aa06",
"readOnly": true,
"format": "uuid",
"type": [
"string"
]
}
},
"links": [
{
"description": "Register bool value",
"href": "/bool/register",
"title": "detail",
"method": "POST",
"rel": "create",
"schema": {
"properties": {
"bool": {
"description": "bool",
"example": true,
"type": [
"boolean"
]
}
},
"required": [
"bool"
]
},
"targetSchema": {
"properties": {
"id": {
"$ref": "#/definitions/misc/definitions/id"
},
"isTrue": {
"description": "isTrue",
"example": true,
"type": [
"boolean"
]
}
},
"required": [
"id",
"isTrue"
]
}
}
],
"properties": {
"id": {
"$ref": "#/definitions/user/definitions/id"
}
},
"required": [
"id"
]
},
"task": {
"$schema": "http://json-schema.org/draft-04/hyper-schema",
"title": "Task",
Expand Down Expand Up @@ -353,6 +423,9 @@
"error": {
"$ref": "#/definitions/error"
},
"misc": {
"$ref": "#/definitions/misc"
},
"task": {
"$ref": "#/definitions/task"
},
Expand Down
55 changes: 55 additions & 0 deletions _example/doc/schema/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Tasky-App-Version 1.0.0
## The table of contents

- <a href="#resource-error">Error</a>
- <a href="#resource-misc">Misc</a>
- <a href="#link-POST-misc-/bool/register">POST /bool/register</a>
- <a href="#resource-task">Task</a>
- <a href="#link-GET-task-/tasks/{(%23%2Fdefinitions%2Ftask%2Fdefinitions%2Fidentity)}">GET /tasks/{task_id}</a>
- <a href="#link-POST-task-/tasks">POST /tasks</a>
Expand All @@ -47,6 +49,59 @@ This resource represents API error
| **errorFields/name** | *string* | param field name | `"status"` |


## <a name="resource-misc">Misc</a>

Stability: `prototype`

Misc

### Attributes

| Name | Type | Description | Example |
| ------- | ------- | ------- | ------- |
| **[id](#resource-user)** | *uuid* | user id | `"ec0a1edc-062e-11e7-8b1e-040ccee2aa06"` |

### <a name="link-POST-misc-/bool/register">Misc detail</a>

Register bool value

```
POST /bool/register
```

#### Required Parameters

| Name | Type | Description | Example |
| ------- | ------- | ------- | ------- |
| **bool** | *boolean* | bool | `true` |



#### Curl Example

```bash
$ curl -n -X POST https://tasky.io/v1/bool/register \
-d '{
"bool": true
}' \
-H "Content-Type: application/json"
```


#### Response Example

```
HTTP/1.1 201 Created
```

```json
{
"id": "ec0a1edc-062e-11e7-8b1e-040ccee2aa06",
"isTrue": true
}
```


## <a name="resource-task">Task</a>

Stability: `prototype`
Expand Down
48 changes: 48 additions & 0 deletions _example/doc/schema/schemata/misc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
"$schema": http://json-schema.org/draft-04/hyper-schema
title: Misc
description: Misc
stability: prototype
strictProperties: true
type:
- object

definitions:
id:
description: misc id
example: "ec0a1edc-062e-11e7-8b1e-040ccee2aa06"
readOnly: true
format: uuid
type: string

links:
- description: "Register bool value"
href: "/bool/register"
title: detail
method: POST
rel: create
schema:
properties:
bool:
description: bool
example: true
type: boolean
required:
- bool
targetSchema:
properties:
id:
$ref: "/schemata/misc#/definitions/id"
isTrue:
description: isTrue
example: true
type: boolean
required:
- id
- isTrue
properties:
id:
$ref: "/schemata/user#/definitions/id"
required:
- id
id: schemata/misc

0 comments on commit 559e545

Please sign in to comment.