Home / Function/ add() — fastify Function Reference

add() — fastify Function Reference

Architecture documentation for the add() function in schemas.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  4ce65f0a_4a08_48af_a425_a19c8e838029["add()"]
  e8bb6056_4217_c2ca_89f1_f68e8b759a9f["schemas.js"]
  4ce65f0a_4a08_48af_a425_a19c8e838029 -->|defined in| e8bb6056_4217_c2ca_89f1_f68e8b759a9f
  style 4ce65f0a_4a08_48af_a425_a19c8e838029 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/schemas.js lines 20–37

Schemas.prototype.add = function (inputSchema) {
  const schema = fastClone((inputSchema.isFluentSchema || inputSchema.isFluentJSONSchema || inputSchema[kFluentSchema])
    ? inputSchema.valueOf()
    : inputSchema
  )

  // developers can add schemas without $id, but with $def instead
  const id = schema.$id
  if (!id) {
    throw new FST_ERR_SCH_MISSING_ID()
  }

  if (this.store[id]) {
    throw new FST_ERR_SCH_ALREADY_PRESENT(id)
  }

  this.store[id] = schema
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does add() do?
add() is a function in the fastify codebase, defined in lib/schemas.js.
Where is add() defined?
add() is defined in lib/schemas.js at line 20.

Analyze Your Own Codebase

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

Try Supermodel Free