redocly-cli
redocly-cli copied to clipboard
Support jsonschema vocabularies
Describe the bug Show error on valid jsonschema with vocabularies.
https://json-schema.org/understanding-json-schema/reference/schema.html#vocabularies
To Reproduce Steps to reproduce the behavior:
openapi: 3.1.0
info:
title: example
version: 1.0.0
description: example
contact:
email: [email protected]
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: https://google.com
tags:
- name: user
description: user
paths:
/users:
post:
tags:
- user
operationId: dteDetalhe
description: example
summary: example
requestBody:
content:
application/json:
schema:
type: integer
units: kg
isEven: true
Running this command
redocly lint test.yaml --format=stylish
Show this message:
No configurations were defined in extends -- using built in recommended configuration by default.
Warning! This default behavior is going to be deprecated soon.
validating test.yaml...
test.yaml:
29:15 error spec Property `units` is not expected here.
30:15 error spec Property `isEven` is not expected here.
test.yaml: validated in 25ms
❌ Validation failed with 2 errors.
run `openapi lint --generate-ignore-file` to add all problems to the ignore file.
Expected behavior Woohoo! Your OpenAPI definition is valid. 🎉
Redocly Version(s) 1.0.0-beta.100
Node.js
Version(s)
v14.15.1
There are two things here:
-
lint should not error for unknown keys in json schema as random keys are actually allowed in JSON Schema. I would not make this a default though as most people use default json schema vocab so they will benefit from these errors.
-
actual support for meta-schema, this is a bigger scope. We are still considering it. So far it looks like not many people actually use it. If we see more demand we'll probably implement it.
Adding an option somewhere to configure whether to report should help with 1.
We can consider support for "Meta-data keywords" because:
Meta-data keywords are the most interoperable because they don’t affect validation. For example, you could add a units keyword. This will always work as expecting with an compliant validator.
You can bypass this to run lint. But when I try to use the view of the same specification in the VSCode extension, I see the following messages:
We found structural problems in your definition, please check the files below before running the preview.
File: /home/user/test.yaml
Problem: Property `units` is not expected here.
File: /home/user/test.yaml
Problem: Property `isEven` is not expected here.
It could be linked to an older version. Does it still have this issue with the latest VS Code extension @lucianojs ?
@adamaltman
Yes, still have this issue on VSCode.
Release 0.2.11 (2022-07-04) of plugin.
We didn't fix it yet. We should get it done soon.