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

JsonSchemaViewer does not respect showSideNav attribute. #781

Open
nnaku opened this issue Jul 8, 2022 · 6 comments
Open

JsonSchemaViewer does not respect showSideNav attribute. #781

nnaku opened this issue Jul 8, 2022 · 6 comments

Comments

@nnaku
Copy link

nnaku commented Jul 8, 2022

I'm trying to inject following html to tag description. Theme and header attributes works as expected but I cannot hide the side nav.

<json-schema-viewer
  spec-url="data:;base64,;..."
  theme="light"
  show-header="false"
  show-side-nav="false">
</json-schema-viewer>

And why? Well, we have websocket on same server and I like to just list event payloads in description. Keeping all the stuff in same apidoc feels better than docs scattered all over the places.

@mrin9
Copy link
Collaborator

mrin9 commented Jul 8, 2022

And why? Well, we have websocket on same server and I like to just list event payloads in description. Keeping all the stuff in same apidoc feels better than docs scattered all over the places.

OpenAPI do not support documenting WebSocket. So unfortunately you cant

And <rapi-doc> and <json-schema-viewer>are two different web-components made for different purposes you cannot apply rapidoc's attribute to json-schema-viewer and expect it to work
json-schema-viewer is not yet made public nor we provide any documentation or usage example for this component. It is intended to show certain schema documentations that are loosely based on json-schema spec, such as MongoDB / DocumentDB, Elasticsearch / OpenSearch, Avro Schema etc.

Still if you like to document WebSockets using OpenAPI, IMO using markdown and use a table or code-block in descriptions to document your schemas and related details. That way you can have the entire spec in one document.

And the other option would be to use AsyncAPI to document your REST API and WebSocket both in a single place

@nnaku
Copy link
Author

nnaku commented Jul 12, 2022

OpenAPI do not support documenting WebSocket. So unfortunately you cant

Well, I didn't suggest or ask for WebSocket support. I'm just asking if it's possible to render any json schema to the description.

json-schema-viewer is not yet made public nor we provide any documentation or usage example for this component. It is intended to show certain schema documentations that are loosely based on json-schema spec, such as MongoDB / DocumentDB, Elasticsearch / OpenSearch, Avro Schema etc.

If you have intend to publish a component in the future.
Let this be feature request or some sort of wish. 😅

@mrin9
Copy link
Collaborator

mrin9 commented Jul 13, 2022

okay I will add this to our queue as a feature request. to allow usage of json-schema-viewer component inside of the rapi-doc component in a more structured way

@shishkin
Copy link

shishkin commented Jul 4, 2023

@nnaku how were you able to pass the schema via the data URL? I'm trying the same and getting error RapiDoc: There was an issue while parsing the spec with:

{
  errors: [],
  resolvedSpec: { /* my correctly decoded json schema */ },
  spec: {}
}

@nnaku
Copy link
Author

nnaku commented Jul 10, 2023

@shishkin here is how i got it working. Its from internal tool so no live example sorry...

const markdownTemplate = ({title, description, spec}) => `
### \`${title}\`

${description}

<div class="event-schema" style="height: auto;">
  <json-schema-viewer 
    spec-url="data:;base64,${Buffer.from(JSON.stringify(spec), 'utf8').toString('base64')}" 
    theme="light" 
    show-side-nav="false" 
    show-header="false" 
    show-info="false" 
    allow-search="false" 
    allow-advanced-search="false">
  </json-schema-viewer>
</div>
`

@shishkin
Copy link

OK, after some debugging it seems the issue I had wasn't with the base64 data URL encoding, but with the expected spec format. From this mongo example and the parser logic I see that json-schema-viewer expects some weird structure like:

jsonSchemaViewer: 1.0.0
schemaAndExamples:
  // real schema goes in here

Is this some kind of standard? Can the json-schema-viewer just accept a plain JSON schema as input?

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

3 participants