redhat-developer / redhat-developer/vscode-yaml

Use openAPIV3Schema from CustomResourceDefinition?

Open
#1,137 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Is your enhancement related to a problem? Please describe.

Given that a lot of projects provide a CRD without a standalone schema, I would like to be able to use the CRD for validation in vscode:

# yaml-language-server: $schema=https://raw.githubusercontent.com/crossplane-contrib/provider-kubernetes/refs/heads/main/examples/in-composition/definition.yaml

There's a schema in the CRD:

spec.versions[].schema.openAPIV3Schema

https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation

Describe the solution you would like

Some way to validate using the openAPIV3Schema from a CustomResourceDefinition (CRD).

Describe alternatives you have considered

Extract the schema using tools such as

openapi2jsonschema

Or

crd-to-openapischema

Or manual extraction

    spec:
      versions:
      - name: v1
        schema:
          openAPIV3Schema:
            type: object
            # ... OpenAPI v3 schema definition ...
Additional context

Related to https://github.com/redhat-developer/yaml-language-server/issues/132 ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing schema validation and schema URL handling in the vscode-yaml extension, then examine the linked yaml-language-server issue. Determine how a CRD's spec.versions[].schema.openAPIV3Schema could be selected and used for validation. Done means a CRD such as the linked definition.yaml can provide validation without manual schema extraction.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, typescript, yaml
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.