microsoft / microsoft/vscode-json-languageservice

OpenApi schema validation

Open
#162 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
326
Forks
145
Avg merge
22h 10m
Merged PRs (30d)
9

Description

Greetings,

I'm wondering if this team has been thinking about if/how to support an openapi spec?

So, in short, the native vscode schema validation has been a pivotal tool with our bigger declarative APIs. It is easy enough to setup file/language associations or $schema references for these individual endpoints.

The problem changes when we start talking about an OpenAPI spec. Now we have many schemas for many different endpoints.

As a prototype, I am able to open a json TextDocument and provide a codeLens with the method/url/schema-ref. On the back side I have an array of tuples that tracks each document with the openapi details like method/url/schema. So, when needed, I can use the current text document to find all the additional information.

I have some ideas on how to get this working and would like some input on how these ideas might fit into your bigger goals;

  1. Add a function/parameter to the text document or json language server to specify the exact json schema to validate the document with.

This would allow me to dynamically provide the necessary schema for each document that gets opened

  1. Extend language server to process openapi spec

For option 2, something like this, could provide enough detail for this service to process;

{
    "$schema": "https://comby.com/some/public/openapi_spec.json",
    "url": "/api/books/",
    "method": "POST",
    "body": {
        "title": "Great Book",
        "author": "Brooks Books",
        "type": "unicorn",
        "pages": 543
    }
}

Contributor guide

No contributing guide indexed for this repository

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 JSON language server and TextDocument capabilities referenced in the issue, then compare the proposed dynamic schema parameter with processing an OpenAPI spec. Done would require a decided scope and documented behavior for one of these approaches, since the issue currently presents alternatives rather than a defined implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.