Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e53c3ff6bb | |||
| a38d007012 |
@@ -115,29 +115,13 @@ given string value.
|
|||||||
|
|
||||||
In the test schema, we can see the following definition:
|
In the test schema, we can see the following definition:
|
||||||
```json
|
```json
|
||||||
"properties": {
|
"Pubkey": {
|
||||||
"from": {
|
"type": "string",
|
||||||
"allOf": [
|
"x-serialization": {
|
||||||
{ "$ref": "#/components/schemas/Pubkey" },
|
"tags": ["ak", "ct"]
|
||||||
{ "x-serialization": {
|
}
|
||||||
"tags": ["ak"]
|
|
||||||
}}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
...
|
|
||||||
"Pubkey": {
|
|
||||||
"type": "string",
|
|
||||||
"x-serialization": {
|
|
||||||
"tags": ["ak", "ct"]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Whenever the validator encounters an `x-...` property mapped to a validator fun,
|
Whenever the validator encounters an `x-...` property mapped to a validator fun,
|
||||||
this fun is called with the value and the schema part of the property. The return
|
this fun is called with the value and the schema part of the property. The return
|
||||||
value of the fun is ignored, and any normal return is treated as a validation success.
|
value of the fun is ignored, and any normal return is treated as a validation success.
|
||||||
|
|
||||||
The example illustrates a common pattern in OpenAPI specs, where entity references are
|
|
||||||
used extensively. The `Pubkey` data type can have a more general `x-serialization`
|
|
||||||
definition, where multiple key types are accepted, whereas a specialized use of the
|
|
||||||
type can narrow the scope by accepting only a subset of the possible types.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user