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

Support for rendering individual JSON schema #253

Closed
proppy opened this issue Jul 1, 2020 · 7 comments
Closed

Support for rendering individual JSON schema #253

proppy opened this issue Jul 1, 2020 · 7 comments

Comments

@proppy
Copy link

proppy commented Jul 1, 2020

It would be nice to support rendering vanilla JSON schema in addition to OpenAPI specs.

Looking at the implementation of <schema-tree> and <schema-table>, it seems that they currently get an intermediate representation of the schema thru their .data attributes.

Do you think it would be desirable to extend those components to allow passing a JSON schema thru the element body, or would you rather see another component by introduced, ex:

<rapi-schema>
   <pre>
{
  "$schema": "http:https://json-schema.org/draft-07/schema#",
  "$id": "http:https://example.com/product.schema.json",
  "title": "Product",
  "description": "A product from Acme's catalog",
  "type": "object",
  "properties": {
    "productId": {
      "description": "The unique identifier for a product",
      "type": "integer"
    }
  },
  "required": [ "productId" ]
}
   </pre>
</rapi-schema>

(using a <pre> would allow to fallback to just displaying the raw schema.

@mrin9
Copy link
Collaborator

mrin9 commented Jul 3, 2020

I would like to know about the use case here,
open api schema is a subset of JSON schema so how will it get used up, assuming we create a component from json-schema ?

@proppy
Copy link
Author

proppy commented Jul 3, 2020

My understanding is that w/ OpenAPI 3.1 both will now be aligned (see OAI/OpenAPI-Specification#1977) and OpenAPI schema will now be a superset (or vocabulary) of JSON Schema draft 2019-09.

The use case would be to render individual JSON schema using Table or Tree schema display style (like in https://mrin9.github.io/RapiDoc/examples/schema-table.html#get-/schema/person) without the need to create a full OpenAPI spec.

@mrin9
Copy link
Collaborator

mrin9 commented Jul 5, 2020

Well, we arn't there yet.
Our dynamic converter if you throw an OpenAPI/Swagger 2.0 will convert to OpenAPI 3.0.x

But, I am glad you brought it up. I have added this to our task list and will back it up with feature-request
I wont be able to commit to any timeline yet, but will be something that will be supporting within the boundary of OpenAPI 3.1

If that means its same as JSON-Schema draft 2019 then even better

proppy added a commit to proppy/RapiDoc that referenced this issue Jul 6, 2020
This change allow usage of <schema-tree> and <schema-table> custom
element with a child <pre> block containing a JSON schema.

Fixes rapi-doc#253
@proppy
Copy link
Author

proppy commented Jul 6, 2020

@mrin9 gave it a try with #258 let me know if that's going in the right direction.

proppy added a commit to proppy/RapiDoc that referenced this issue Jul 27, 2020
Act as a wrapper for schema-table and schema-tree to render inline
JSON schemas

Fixes rapi-doc#253
proppy added a commit to proppy/RapiDoc that referenced this issue Jul 27, 2020
Act as a wrapper for `<schema-table>` and `<schema-tree>` to render
inline JSON schemas.

Fixes rapi-doc#253
@mrin9
Copy link
Collaborator

mrin9 commented Nov 12, 2020

please refer to my comments on the PR.

@mrin9 mrin9 closed this as completed Nov 12, 2020
@shishkin
Copy link

shishkin commented Jul 4, 2023

Would really be nice to render just a json schema alone using a subcomponent of this library.

@shishkin
Copy link

shishkin commented Jul 4, 2023

I actually saw in #781 that this is already somewhat available in https://github.com/rapi-doc/RapiDoc/blob/master/src/json-schema-viewer.js.

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

Successfully merging a pull request may close this issue.

3 participants