Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 1.13 KB

3-json-schema.md

File metadata and controls

32 lines (23 loc) · 1.13 KB

🌇 Architecture & Paradigms

JSON Schema

Learning how to write JSON schemas has become a staple of the JavaScript and Node.js ecosystem for me lately. More and more tools and frameworks use schemas for validation, creation of JSON OpenAPI usable in a Swagger interface etc.

The most telling example is certainly the Fastify.js framework. Nevertheless within the framework of the SlimIO project the diagrams are also omnipresent in the management of the configurations.

The AJV package is the go-to solution if you want to experiment and work with it.

const headersJsonSchema = {
  type: "object",
  properties: {
    Authorization: {
      type: "string",
      pattern: "Bearer .+"
    }
  },
  required: ["Authorization"]
};

Additional links


⬅️ 🌇 Architecture & Paradigms: CalVer | ➡️ 🌇 Architecture & Paradigms: Documentation