Contributing to Meshery Schemas
Overview
Meshery follows schema-driven development. As a project, Meshery has different types of schemas. Some schemas are external facing, and some internal to Meshery itself. This repository serves as a central location for storing schemas from which all Meshery components can take reference.
The schemas follow a versioned approach to maintain backward compatibility while allowing for the evolution of the definitions.
Meshery Documentation Core Concepts
To better understand how schemas fit into Meshery's architecture, read about Meshery's core concepts in the Meshery documentation.`Prerequisites
- oapi-codegen: This tool is essential for generating Go code from OpenAPI specifications. Install it using:
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
- make: The repository uses Makefiles to automate various tasks. Ensure you have make installed on your system.
Development Workflow
Schema Definition in Meshery
Meshery uses OpenAPI v3 specification to define schemas. Given the complexity of the project, where multiple constructs and APIs exist, we adopt a structured approach to schema management:
- Schemas are versioned to maintain backward compatibility.
- Schemas are modular to support different components of Meshery independently.
- Schemas are used for validation, API definition, and automatic code generation.
Schema Directory Structure
All schemas are stored in the schemas
directory at the root of the project. The structure follows:
schemas/
constructs/
<schema-version>/ # e.g., v1beta1
<construct>/ # e.g., model, component
<construct>.json # Schema definition for the construct (noun)
subschemas/ # Any subschemas used within the construct
openapi.yml # OpenAPI schema defining API operations (verbs like create, update, delete)
Explanation
constructs/
β Contains schemas for different versions.<schema-version>/
β Each schema version (e.g.,v1beta1
,v1alpha2
) is a separate directory.<construct>/
β Each construct (e.g.,capability
,category
) has its own folder.<construct>.json
β Defines the schema for the noun (i.e., the entity).subschemas/
β Contains reusable subschemas for modularity.openapi.yml
β Defines API operations (verbs:create
,update
,delete
) and serves as the entry point for the schema.
This approach ensures that schemas are well-organized, reusable, and scalable across different Meshery components.
Adding a New Schema
To add a new schema, follow these steps:
- Create a new directory under
schemas/constructs/
for the new schema version. - Create a new directory for the construct under the version directory.
- Define the schema in JSON format and save it as
<construct>.json
. - Create a subschemas directory if needed, and add any reusable subschemas.
- Define the OpenAPI schema in
openapi.yml
to specify API operations. - Update the
generate.sh
script to include the new schema for code generation. - Run the code generation script to generate the necessary code files.
Code Generation
Meshery supports automatic code generation for:
- Golang (structs and types)
- TypeScript (interfaces and types)
Generating Code from Schemas
The schema-to-code mapping is defined in generate.sh
, which automates the generation process.
Generating Golang Models
To generate Go structs from schemas, use:
make golang-generate
This also generates a merged_openapi.yml file which can be used to generate the redoc documentation and for rtk-api
Generating TypeScript Models
To generate TypeScript types and and ts objects for the schemas use:
make generate-ts
This will generate the typescript types and also javascript objects for the schemas the javascript objects can be used to do run time validation of data or for getting information from the schema
Schema-to-Code Mapping
Example mapping in generate.sh
:
generate_schema_models <construct> <schema-version>
generate_schema_models "capability" "v1alpha1"
generate_schema_models "category" "v1beta1"
generate_schema_models "component" "v1beta1"
generate_schema_models "pattern" "v1beta1" "schemas/constructs/v1beta1/design/openapi.yml"
generate_schema_models "core" "v1alpha1"
generate_schema_models "catalog" "v1alpha2"
- The package name matches the construct name.
- Example: For the
capability
construct inv1alpha1
, the generated Go code will be in:models/v1alpha1/capability/capability.go
Example Output
./generate-golang.sh
πΉ Processing: capability (v1alpha1)...
β
Generated: models/v1alpha1/capability/capability.go
πΉ Processing: category (v1beta1)...
β
Generated: models/v1beta1/category/category.go
πΉ Processing: pattern (v1beta1)...
β
Generated: models/v1beta1/pattern/pattern.go
πΉ Processing: core (v1alpha1)...
β
Generated: models/v1alpha1/core/core.go
πΉ Processing: catalog (v1alpha2)...
β
Generated: models/v1alpha2/catalog/catalog.go
This ensures that schemas remain the single source of truth, making development efficient, consistent, and scalable.
Getting Help
- GitHub Issues - Report bugs or request features
- Community Slack - Real-time discussions with maintainers
- Weekly Meetings - Join our community calls
Community Resources For more contribution guidelines, see the Meshery Contributing Guide.
Suggested Reading
- Build & Release (CI) - Details of Meshery's build and release strategy.
- Contributing to Meshery Adapters - How to contribute to Meshery Adapters
- Contributing to Meshery CLI End-to-End Tests - How to contribute to Meshery Command Line Interface end-to-end testing with BATS.
- Contributing to Meshery CLI - How to contribute to Meshery Command Line Interface.
- Contributing to Meshery Docker Extension - How to contribute to Meshery Docker Extension
- Meshery Documentation Structure and Organization - Audience, high-Level outline & information architecture for Meshery Documentation
- Contributing to Meshery Docs - How to contribute to Meshery Docs.
- How to write MeshKit compatible errors - How to declare errors in Meshery components.
- Contributing to Meshery using git - How to contribute to Meshery using git
- Meshery CLI Contributing Guidelines - Design principles and code conventions.
- Contributing to Model Components - How to contribute to Meshery Model Components
- Contributing to Model Relationships - How to contribute to Meshery Models Relationships, Policies...
- Contributing to Models Quick Start - A no-fluff guide to creating your own Meshery Models quickly.
- Contributing to Models - How to contribute to Meshery Models, Components, Relationships, Policies...
- Contributing to Meshery Policies - How to contribute to Meshery Policies
- Contributing to Meshery Server Events - Guide is to help backend contributors send server events using Golang.
- Contributing to Meshery UI - Notification Center - How to contribute to the Notification Center in Meshery's web-based UI.
- Contributing to Meshery UI - Sistent - How to contribute to the Meshery's web-based UI using sistent design system.
- Contributing to Meshery UI End-to-End Tests - How to contribute to end-to-end testing in Meshery UI using Playwright.
- Contributing to Meshery UI - Dashboard Widgets - Guide to extending Meshery dashboards with custom widgets.
- Contributing to Meshery UI - How to contribute to Meshery UI (web-based user interface).
- Contributing to Meshery Server - How to contribute to Meshery Server
- Setting up Meshery Development Environment on Windows - How to set up Meshery Development Environment on Windows
- End-to-End Test Status - Status reports of Meshery's various test results.