Home / File/ schema-examples.test.js — fastify Source File

schema-examples.test.js — fastify Source File

Architecture documentation for schema-examples.test.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const { test } = require('node:test')
const localize = require('ajv-i18n')
const Fastify = require('..')

test('Example - URI $id', (t, done) => {
  t.plan(1)
  const fastify = Fastify()
  fastify.addSchema({
    $id: 'http://example.com/',
    type: 'object',
    properties: {
      hello: { type: 'string' }
    }
  })

  fastify.post('/', {
    handler () { },
    schema: {
      body: {
        type: 'array',
        items: { $ref: 'http://example.com#/properties/hello' }
      }
    }
  })

  fastify.ready(err => {
    t.assert.ifError(err)
    done()
  })
})

test('Example - string $id', (t, done) => {
  t.plan(1)
  const fastify = Fastify()
  fastify.addSchema({
    $id: 'commonSchema',
    type: 'object',
    properties: {
      hello: { type: 'string' }
    }
  })

  fastify.post('/', {
    handler () { },
    schema: {
      body: { $ref: 'commonSchema#' },
      headers: { $ref: 'commonSchema#' }
    }
  })

  fastify.ready(err => {
    t.assert.ifError(err)
    done()
  })
})

test('Example - get schema', (t, done) => {
  t.plan(1)
// ... (602 more lines)

Frequently Asked Questions

What does schema-examples.test.js do?
schema-examples.test.js is a source file in the fastify codebase, written in javascript.
Where is schema-examples.test.js in the architecture?
schema-examples.test.js is located at test/schema-examples.test.js (directory: test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free