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

Global json schema (auto versioning) #195

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jkellerer
Copy link
Collaborator

This PR:

The is the first step to add the schema to the schemastore catalog (we need a single schema for this) and is also more convenient if the URL doesn't need to be changed 😀

This simplifies the schema and makes it more compatible (config-1)
@codecov
Copy link

codecov bot commented Apr 17, 2023

Codecov Report

Patch coverage: 95.00% and project coverage change: +0.04 🎉

Comparison is base (7f8554f) 76.02% compared to head (d458c2f) 76.05%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
+ Coverage   76.02%   76.05%   +0.04%     
==========================================
  Files          93       93              
  Lines        9777     9784       +7     
==========================================
+ Hits         7432     7441       +9     
  Misses       2086     2086              
+ Partials      259      257       -2     
Impacted Files Coverage Δ
config/global.go 84.21% <ø> (ø)
config/jsonschema/model.go 94.26% <92.86%> (-0.16%) ⬇️
commands.go 55.65% <100.00%> (+0.93%) ⬆️
config/jsonschema/schema.go 97.98% <100.00%> (-0.04%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jkellerer jkellerer force-pushed the ft-global-jsonschema branch 2 times, most recently from 91638dd to e38130c Compare April 19, 2023 12:50
@jkellerer
Copy link
Collaborator Author

After some adjustments it works well for YAML and JSON now. "Even better TOML" doesn't support if/then/else, but without it, YAML and JSON report errors incorrectly, since not setting a version is also an error when only using implication and it is the first and only reported error in this case.

One improvement for "Even better TOML" however is that the updated version-1 schema now also works correctly. Previously it didn't support profile commands due to the lack of full regex support in the editor plugin.

For testing with local references, run:

SCHEMA_BASE_URL="http://localhost:1313/resticprofile/jsonschema" \
resticprofile generate --config-reference contrib/templates/config-schema.gojson > docs/static/jsonschema/config.json

Auto selection then works with:

# yaml-language-server: $schema=http://localhost:1313/resticprofile/jsonschema/config.json
version: "2"

global:
  restic-version: "0.15"

@jkellerer jkellerer marked this pull request as ready for review April 19, 2023 13:16
@creativeprojects
Copy link
Owner

This looks good to me, thanks for this PR 👍🏻

I was trying the new configuration locally but it seems that it doesn't recognise the version 2. Am I doing something wrong?

Screenshot 2023-04-22 at 23 13 53

@jkellerer
Copy link
Collaborator Author

Might be due to implication. While most examples indicate that it should be fine to use it for versioning, I think it needs to be updated to select all versions first using if/then/else and only when this validates, choose a schema for the rest of the document. Otherwise editors will always struggle with priority of errors (or fail to select a different schema).

Will update the template.

@creativeprojects
Copy link
Owner

Thanks!

I had a quick look at the JSON schema specs and hmmm it does look cutting edge 😐

@jkellerer jkellerer added the enhancement New feature or request label Jun 10, 2023
@jkellerer jkellerer marked this pull request as draft June 10, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants