Schemas

triangle-exclamation

This page was deprecating! Please use Schematorarrow-up-right middleware

Swagger documentation generated based on schemas

circle-info

If you correctly and exactly define the schema, your app will be faster by 25-30% which is good and validation support will be out-of-the-box

Validation

circle-info

All validations are optional

Types of validation

  • headers

  • params

  • query

  • body

  • cookies

circle-info

For more information, please look at Ajv docsarrow-up-right

circle-info

If you don't want to use any or all (except body) of these validation method, please set it to false for performance reason

app.get(
  '/',
  {
    schema: {
      headers: {
        type: 'object',
        properties: {
          authorization: { type: 'string' }
        }
      },
      query: false,
      params: false,
      cookies: false
    }
  },
  async () => ({ hello: 'world' })
);

app.listen(4000);

Serialization

Types of serialization

We use fast-json-stringifyarrow-up-right under the hood for serialization and improving response time (applies for Array and Object)

circle-exclamation
circle-info

If required property was used and value isn't returned, server may crash or performance may be dropped by 6-8 times, please, try to make sure everything is correct on your schema

Response content types:

  • response

  • response.HTTP_CODE

HTTP Code-based serialization

Last updated