Skip to content

adrai/fastify-schema-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Schema

{
  $id: 'myObj',
  type: 'object',
  properties: {
    justNullable: { type: 'string', nullable: true },
    nullableAndNullType: { type: ['string', 'null'], nullable: true },
    formatJustNullable: { type: 'string', nullable: true, format: 'email' },
    formatNullableAndNullType: { type: ['string', 'null'], nullable: true, format: 'email' },
    patternJustNullable: { type: 'string', nullable: true, pattern: '^(https?:\\/\\/)?(www\\.)?([a-zA-Z0-9]+(-?[a-zA-Z0-9])*\\.)+[\\w]{2,}(\\/\\S*)?$' },
    patternNullableAndNullType: { type: ['string', 'null'], nullable: true, pattern: '^(https?:\\/\\/)?(www\\.)?([a-zA-Z0-9]+(-?[a-zA-Z0-9])*\\.)+[\\w]{2,}(\\/\\S*)?$' },
  }
}

Response

The response is always:

{
    justNullable: null,
    nullableAndNullType: null,
    formatJustNullable: null,
    formatNullableAndNullType: null,
    patternJustNullable: null,
    patternNullableAndNullType: null
}

and is correctly serialized:

{"justNullable":null,"nullableAndNullType":null,"formatJustNullable":null,"formatNullableAndNullType":null,"patternJustNullable":null,"patternNullableAndNullType":null}

Request

"justNullable": null wil be parsed as: justNullable: '' => expecting: "justNullable": null

"nullableAndNullType": null wil be parsed as: nullableAndNullType: null => like expected

"formatJustNullable": null results in body.formatJustNullable should match format \"email\" => expecting: "formatJustNullable": null

"formatNullableAndNullType": null wil be parsed as: formatNullableAndNullType: null => like expected

"patternJustNullable": null results in body.patternJustNullable should match pattern \"^(https?:\\/\\/)?(www\\.)?([a-zA-Z0-9]+(-?[a-zA-Z0-9])*\\.)+[\\w]{2,}(\\/\\S*)?$\" => expecting: "patternJustNullable": null

"patternNullableAndNullType": null wil be parsed as: patternNullableAndNullType: null => like expected

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published