You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a $ref node has a validation like readOnly or writeOnly in the schema, this parser fails to properly forward this information which results in wrong visualizations in Stoplight Elements depending on the view mode.
Context
This bug has the effect that in @stoplight/json-schema-viewer (and thus Stoplight Elements), readOnly and writeOnly objects ($ref node) are not rendered properly. It was noticed during fixing a bug in a Go REST API library called huma: danielgtaylor/huma#314
Steps to Reproduce
import{SchemaTree}from'@stoplight/json-schema-tree';consttree=newSchemaTree({"$schema": "http://json-schema.org/draft-07/schema#","definitions": {"Nested": {"additionalProperties": false,"properties": {"nestedValue": {"type": "string"},"nestedValue2": {"type": "string"}},"required": ["nestedValue","nestedValue2"],"type": "object"}},"additionalProperties": false,"properties": {"$schema": {"description": "A URL to the JSON Schema for this object.","format": "uri","readOnly": true,"type": "string"},"foo": {"$ref": "#/definitions/Nested","readOnly": true},"foo2": {"$ref": "#/definitions/Nested","writeOnly": true},"bar": {"format": "int64","type": "integer"}},"required": ["bar","foo","foo2"],"type": "object"});tree.populate();tree.root;// populated treefor(constnodeoftree.root.children[0].children){console.log('---');console.log(node.path);console.log(node.fragment);console.log(node.validations);}
When a $ref node has a validation like
readOnly
orwriteOnly
in the schema, this parser fails to properly forward this information which results in wrong visualizations in Stoplight Elements depending on the view mode.Context
This bug has the effect that in
@stoplight/json-schema-viewer
(and thus Stoplight Elements),readOnly
andwriteOnly
objects ($ref node) are not rendered properly. It was noticed during fixing a bug in a Go REST API library called huma: danielgtaylor/huma#314Steps to Reproduce
Current Behavior
trimmed test output:
json-schema-viewer output:
Expected Behavior
trimmed test output:
json-schema-viewer output:
Possible Workaround/Solution
I will mention this issue in a PR with my proposed solution.
Environment
The text was updated successfully, but these errors were encountered: