Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add $schema property to schema #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pke
Copy link

@pke pke commented Oct 27, 2019

What this PR does / why we need it:

VS Code supports code completion for JSON files based on JSON Schema.

Code completion in VS Code picks up a schema for any JSON file if the schema is
specified as "$schema": "<URL to schema>".

It automatically picks up certain JSON Schemas by file name (ie: package.json) and you can configure your own associations via (workspace) settings.json like this:

"json.schemas": [
  {
    "fileMatch": [
      "resume.json"
    ],
    "url": "http://json.schemastore.org/resumic-schema.json"
  }
]

Alternatively VS Code supports the $schema key in JSON files itself.

So in a resume.json we could add the JSON Resumic schema to get code completion without touching the VS Code settings:

{
  "$schema": "http://json.schemastore.org/resumic-schema.json",

}

XML had a similar feature where you could specify an XSD in the XML pre-processing tags to validate the syntax and data (to some extent) of the XML.

Release note:

Add `$schema` property to resumic JSON schema to allow editors like VS Code to offer validation and triggering suggestions.

VS Code supports [code completion for JSON files](https://code.visualstudio.com/docs/languages/json) based on [JSON Schema](https://json-schema.org/specification.html).

Code completion in VS Code picks up a schema for any JSON file if the schema is
specified as `"$schema": "<URL to schema>"`.

It automatically picks up [certain JSON Schemas](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings) by file name (ie: `package.json`) and you can configure your own associations via (workspace) `settings.json` like this:

```json
"json.schemas": [
  {
    "fileMatch": [
      "resume.json"
    ],
    "url": "http://json.schemastore.org/resumic-schema.json"
  }
]
```

Alternatively VS Code supports the `$schema` key in JSON files itself.

So in a `resume.json` we could add the [JSON Resumic schema](http://json.schemastore.org/resumic-schema.json) to get code completion without touching the VS Code settings:

```json
{
  "$schema": "http://json.schemastore.org/resumic-schema.json",

}
```

[XML](https://www.w3.org/TR/2008/REC-xml-20081126/) had a similar feature where you could specify an [XSD](https://www.w3.org/TR/xmlschema-0/) in the XML pre-processing tags to validate the syntax and data (to some extent) of the XML.
@stp-ip
Copy link
Member

stp-ip commented Oct 27, 2019

Great idea. Will look into how this would be possible with a redirect as well.

For the failing tests: We use go as the single source of truth and generate the schema.json as well as the examples from Go. Changing the schema.json itself won't work.
If you can update this, would be awesome.

@pke
Copy link
Author

pke commented Oct 27, 2019

This will take me some time, since I am not familiar with go.

@stp-ip
Copy link
Member

stp-ip commented Oct 28, 2019

Everything schema specific is within https://github.com/resumic/schema/blob/master/schema/schema.go.
It's mostly just around creating the specific struct within go that gets output to a json schema etc.
Happy to help and take the time you need.

@pke
Copy link
Author

pke commented Oct 28, 2019

@stp-ip Which call generates the JSON Schema so I can check it locally before updating this PR?

@stp-ip
Copy link
Member

stp-ip commented Oct 28, 2019

We have a makefile that should test the integrity of the json schema as well as the overlap with the generated examples etc.
make test should give some helpful output.

For the general CLI resumic -h should help navigation.
To check a specific resume against the schema: resumic validate --resume=myresume.json

@stp-ip stp-ip self-assigned this Apr 11, 2020
stp-ip added a commit to stp-ip/resumic-schema that referenced this pull request Apr 11, 2020
stp-ip added a commit to stp-ip/resumic-schema that referenced this pull request Apr 29, 2020
Add peopleSchema
Add image field
Fixes resumic#76

Add schema reference using vanity url
Fixes: resumic#114

Move to numerical enums for skills and language
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants