meshery/schemas/create-openapi-schemas-from-golang-models
Claude Code and agent skill by meshery/schemas
- community
Checking that the SKILL.md file is still in the repository.
Create OpenAPI schemas from Golang models in Meshery Cloud, generating schema artifacts in Meshery Schemas repository. Handles cross-repository schema creation workflow with proper naming conventions, Go code generation, and backwards compatibility validation.
Install
npx vskill@latest install meshery/schemas/create-openapi-schemas-from-golang-modelsSKILL.md
Create OpenAPI Schemas from Golang Models
Canonical naming contract - seedocs/identifier-naming-contributor-guide.mdinmeshery/schemas(<https://github.com/meshery/schemas/blob/master/docs/identifier-naming-contributor-guide.md>) for the full directory (26-row naming table with before/after and do/don't examples). The inline rules below remain the skill's authority for its workflow scope; the guide is the reader-friendly cross-repo reference.
Overview
This skill guides you through creating OpenAPI schemas from existing Golang models in Meshery Cloud (layer5io/meshery-cloud), with the generated schemas stored in Meshery Schemas (meshery/schemas). This cross-repository workflow ensures consistent API contracts between the two projects.
Prerequisites
Required Repositories
Both repositories must be locally cloned and available:
- Meshery Cloud:
/Users/l/code/meshery-cloud(https://github.com/layer5io/meshery-cloud) - Meshery Schemas:
/Users/l/code/schemas(https://github.com/meshery/schemas)
Required Knowledge
- Read the
meshery/schemasREADME.md and uphold all directives, including naming conventions - Read AGENTS.md in both repositories
- Treat the Golang models in
layer5io/meshery-cloudas the source of truth - Ignore any existing schemas in
meshery/schemasfor constructs being worked on - Ignore any existing tests in
layer5io/meshery-cloudfor constructs being worked on
Naming Conventions
OpenAPI Schema Naming
| Element | Convention | Example | |
|---|---|---|---|
| Property names | Preserve published wire-format casing: DB-backed fields use exact snake_case db names; new non-DB fields use camelCase | first_name, organization_id, schemaVersion | |
| Identifier fields | camelCase + "Id" suffix | roleId, userId, keychainId | |
| Enums | lowercase | admin, user, enabled | |
| Object names | singular nouns | role, keychain, user | |
| Schema components | PascalCase | Role, RolesPage, RoleHolderRequest | |
| Files/folders | lowercase | role.yaml, api.yml |
Endpoint Naming
| Element | Convention | Example | |
|---|---|---|---|
| Paths | /api + kebab-case plurals | /api/identity/orgs/{orgId}/roles | |
| Operations | camelCase VerbNoun | GetAllRoles, UpsertRoles |
If a property has x-oapi-codegen-extra-tags.db and that db value is snake_case, the schema property name and JSON tag must use that exact snake_case name. Do not camelize DB-backed fields in-place within an existing API version. Pagination envelopes must use page, page_size, and total_count.
Response descriptions and response message text must not include the word successfully. Use neutral wording such as Role deleted, Webhook processed, or Roles response.
Workflow
Task 1: Create Schema Artifacts
In meshery/schemas, create these files for the target construct:
Dual-Schema Pattern (required): Every entity needs two schemas -<construct>.yaml(full response entity) and{Construct}Payloadinapi.yml(write request body). Never use the entity schema as aPOST/PUTrequestBody. See AGENTS.md § "The Dual-Schema Pattern" for full rules.
Schema Definition (<construct_name>.yaml)
This is the response schema - the full persisted object as the API returns it. It must:
- Have
additionalProperties: falseat the top level - Include all server-generated fields (
id,created_at,updated_at,deleted_at) inpropertiesandrequired
Map Golang struct fields to OpenAPI properties:
API Definition (api.yml)
Define endpoints matching the Meshery Cloud router. All POST/PUT operations must use a {Construct}Payload request body - never the full entity schema.
Go Type Hints
For cross-schema references, use x-go-type to avoid redundant structs:
Task 2: Generate Go Models
In the meshery/schemas repository:
Verification Steps:
- Ensure generated models are in
models/v1beta1/<construct_name>/ - If a schema type within the construct is stored as a JSON blob in a database column and has a dedicated schema definition with explicit properties, add
x-generate-db-helpers: trueat the schema component level inapi.yml. This instructs the generator to produceScan()andValue()SQL driver methods automatically inzz_generated.helpers.go- no manualhelpers.gois needed for that type.
``yaml # In api.yml, under components/schemas: Quiz: x-generate-db-helpers: true # ← schema-level, not per-property type: object properties: id: $ref: "../../v1alpha1/core/api.yml#/components/schemas/uuid" title: type: string ``
For amorphous JSON blob fields that lack a fixed schema definition (e.g., a freeform metadata map), use x-go-type: "core.Map" on the property instead - do not use x-generate-db-helpers for those.
- If helpers are still needed for non-generated behavior (e.g.,
TableName(), custom business logic), createhelpers.gomanually. When implementingScan/Value, follow these rules (see docs/schema-authoring-reference.md § "SQL Driver (Scan/Value) Implementation Rules"):
Value()must always marshal - never return(nil, nil). A nil map produces JSON"null", not SQL NULL.Scan()must zero the receiver (*m = nil) whensrcis nil, not silently return.
- Create/update tests:
- Run full test suite:
Task 3: Validate Backwards Compatibility
Compare generated models with Meshery Cloud models:
Source: layer5io/meshery-cloud/server/models/<construct>.go Generated: meshery/schemas/models/v1beta1/<construct_name>/<construct_name>.go
Validation Checklist:
- [ ] All fields present with matching types
- [ ] JSON tags match the schema property name exactly; do not treat
snake_caseandcamelCaseas interchangeable for DB-backed fields - [ ]
omitemptybehavior preserved - [ ] Nullable fields handled correctly
- [ ] Array/slice types match
Common Patterns
Pagination Response
UUID Fields
Nullable Time Fields
String Arrays (pq.StringArray)
Exemplar: Academy Construct
The Academy construct in meshery/schemas serves as the primary exemplar for this workflow. Study these files:
Reference Files
| File | Location | Purpose | |
|---|---|---|---|
api.yml | assets/academy-api.yml | Complete OpenAPI schema with paths and components | |
helpers.go | assets/academy-helpers.go | Custom driver methods (NOT auto-generated) | |
| Documentation | references/meshery-schemas-academy.md | Detailed patterns and explanations |
Key Patterns from Academy
- Cross-schema references using
$refwith external files - Custom Go type mappings with
x-go-typeandx-go-type-import - Nullable fields using
core.NullTime - Enum definitions with proper Go type hints
- SQL Scanner/Valuer implementations in helpers.go
Source Repository
- Schema: https://github.com/meshery/schemas/blob/master/schemas/constructs/v1beta1/academy/api.yml
- Go Models: https://github.com/meshery/schemas/tree/master/models/v1beta1/academy
Example: Role Construct
Source Files in Meshery Cloud
- Model:
server/models/roles.go - Handler:
server/handlers/roles.go - DAO:
server/dao/roles_dao.go - Routes:
server/router/router.go(search for "roles")
Key Endpoints
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/create-openapi-schemas-from-golang-models/SKILL.md
Popularity
- Repository stars
- 68
- Repository forks
- 105
- Repository npm downloads, 7 days
- 1,341
- 7-day trend score
- 39
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 22 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/meshery/schemas/create-openapi-schemas-from-golang-models)