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

Root definitions do not display details if not "type" == "object" #36

Open
bmaranville opened this issue Jun 14, 2022 · 1 comment
Open

Comments

@bmaranville
Copy link

If a subschema has been defined that does not have an explicit or implicit type "object", the viewer shows only the description for that subschema when it is clicked in the "Root definitions" tree. It would be nice if the viewer was able to display subschemas of type "enum", "string", etc.

E.g. for this schema:

 {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "id",
  "title": "Orso",
  "type": "object",
  "properties": {},
  "definitions": {
    "Polarization": {
      "title": "Polarization",
      "description": "The first symbol indicates the magnetisation direction of the incident beam (or o for unknown polarization).\n\nThe second symbol indicates the direction of the scattered beam (or o for unknown polarization).",
      "enum": [
        "unpolarized",
        "po",
        "mo",
        "op",
        "om",
        "mm",
        "mp",
        "pm",
        "pp"
      ]
    }
  }
}

The view when clicking on "Polarization" is this:
image

But I'd like it to be this:
image

@bmaranville
Copy link
Author

I pasted in a simple else block to the SchemaExplorerDetails function that generates the second version, but I don't know if it's a reasonable solution:

diff --git a/src/SchemaExplorer.tsx b/src/SchemaExplorer.tsx
index 1a88294..6901e6c 100644
--- a/src/SchemaExplorer.tsx
+++ b/src/SchemaExplorer.tsx
@@ -373,6 +373,17 @@ export const SchemaExplorerDetails: React.FC<SchemaExplorerDetailsProps> = props
       </>
     )
   }
+  else {
+    allRenderedProperties = (
+      <ParameterView
+        name={schema.name}
+        schema={schema}
+        reference={reference}
+        lookup={lookup}
+        clickElement={clickElement}
+      />
+    )
+  }
 
   return (
     <div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant