-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(getSchemaForEndpoint): fastify serializer compatible schema
- Loading branch information
1 parent
26f9fe4
commit fa30a83
Showing
8 changed files
with
288 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
stake_address: | ||
type: string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
export const convertType = [ | ||
{ | ||
description: 'perfectly fine object that does not need transformation', | ||
data: { | ||
type: 'object', | ||
properties: { | ||
key: { | ||
type: 'object', | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
result: { | ||
properties: { | ||
key: { | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
{ | ||
description: 'nullable object', | ||
data: { | ||
type: 'object', | ||
properties: { | ||
key: { | ||
type: ['object', 'null'], | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
result: { | ||
properties: { | ||
key: { | ||
nullable: true, | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
{ | ||
description: 'array with nullable object', | ||
data: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
key: { | ||
type: ['object', 'null'], | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
result: { | ||
type: 'array', | ||
items: { | ||
properties: { | ||
key: { | ||
nullable: true, | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
}, | ||
{ | ||
description: 'object with array type of length 1', | ||
data: { | ||
type: 'object', | ||
properties: { | ||
key: { | ||
type: ['object'], | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
result: { | ||
properties: { | ||
key: { | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
type: 'object', | ||
}, | ||
}, | ||
]; | ||
|
||
export const convertTypeError = [ | ||
{ | ||
description: 'array type with 2 types should throw', | ||
data: { | ||
type: ['object', 'string'], | ||
properties: { | ||
key: { | ||
type: 'object', | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
result: `Error in {"type":["object","string"],"properties":{"key":{"type":"object","properties":{"nestedkey":"string"}}}}. Type doesn't support an array with multiple values. Use anyOf/oneOf.`, | ||
}, | ||
{ | ||
description: 'array type with multiple types should throw', | ||
data: { | ||
type: ['object', 'string', 'integer'], | ||
properties: { | ||
key: { | ||
type: 'object', | ||
properties: { | ||
nestedkey: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
result: `Error in {"type":["object","string","integer"],"properties":{"key":{"type":"object","properties":{"nestedkey":"string"}}}}. Type doesn't support an array with multiple values. Use anyOf/oneOf.`, | ||
}, | ||
]; |
Oops, something went wrong.