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

feat: show event examples #54

Open
1 task done
thim81 opened this issue Jan 12, 2022 · 8 comments
Open
1 task done

feat: show event examples #54

thim81 opened this issue Jan 12, 2022 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@thim81
Copy link
Contributor

thim81 commented Jan 12, 2022

Have you read the Contributing Guidelines on issues?

Description

Currently the application can display an Event Schema (JSON schema representation) and Code Examples.

It would also be nice to show an example of the "event" itself, especially if the event is in a JSON or non-binary format.
Where you see the "Event Schema" and the "Event Example" next to each other.

Example: https://redocly.github.io/redoc/#tag/pet

2022-01-12 at 14 09 50

Motivation

A common use-case for event documentation, is to have an actual example that makes the documentation and event very visual. An event schema describes the properties and the details on these properties. An event example shows the event content/data.

@thim81 thim81 changed the title Show event examples feat: show event examples Jan 19, 2022
@dytyniuk
Copy link
Contributor

Hi @thim81

Can the Code Examples feature help with your case?

@boyney123
Copy link
Owner

Hey @thim81 ,

Thanks for the idea, just looking at everything now, I was certain this was supported already but I can't find anything 😅, yeah great idea. I guess we could add /event-examples directory or something inside the events and let peolpe just add any filetype they want and have the UI render it?

Following from @dytyniuk yeah I guess Code Examples could work there too, but I guess if we had an explicit place we could store this stuff might be better?

Any ideas on where we could store examples of the events? My thoughts is add a new directory and if events are in there maybe the UI can render them, or user opt-in into new component

@thim81
Copy link
Contributor Author

thim81 commented Jun 11, 2022

hi @boyney123

Adding /event-examples directory would be a very logical solution.

The tricky part will be the rendering part and I guess mostly the UI aspect, like where to put the example in the event details screen.

image

Where to put this?

@dytyniuk
Copy link
Contributor

dytyniuk commented Jun 12, 2022

hi @boyney123

I thought about your suggestion to add the event-examples directory a bit. And here is what I have come through:

  1. At first I had a thought, it would be enough to have a single example of the event. Just like with its' schema -- if you have some other example, that could be lookling as a new version of the event. So, an example based on a single file looked legit.
  2. Although, I have realised, that the event can contain optional properties, and one may need to show more that one example.
  3. You have already implemeted the examples directory to keep code samples. How about adding an extra directory there? Something like this:
└─ events
   ├─ index.md
   ├─ schema.json
   └─ examples
      ├─ code-sample.js
      └─ event
         ├─ example-a.json
         └─ example-b.json

@thim81 does look like something helping with your issue?

@boyney123
Copy link
Owner

hi @boyney123

Adding /event-examples directory would be a very logical solution.

The tricky part will be the rendering part and I guess mostly the UI aspect, like where to put the example in the event details screen.

image

Where to put this?

Maybe an MDX Component that people can choose where to put it.

I might also explore some kind of component that allows people to put things side by side, in your example it could be

<Splitter>
    <SchemaViewer/>
    <EventExample example="example1" />
</Splitter>

This could render the things side by side and allow you to choose which event example to render

@thim81
Copy link
Contributor Author

thim81 commented Jun 17, 2022

@boyney123 The <splitter> would be really interesting, since you typically want to have the example and schema properties in 1 view to be able to understand what is shown.

@boyney123
Copy link
Owner

hi @boyney123

I thought about your suggestion to add the event-examples directory a bit. And here is what I have come through:

  1. At first I had a thought, it would be enough to have a single example of the event. Just like with its' schema -- if you have some other example, that could be lookling as a new version of the event. So, an example based on a single file looked legit.
  2. Although, I have realised, that the event can contain optional properties, and one may need to show more that one example.
  3. You have already implemeted the examples directory to keep code samples. How about adding an extra directory there? Something like this:
└─ events
   ├─ index.md
   ├─ schema.json
   └─ examples
      ├─ code-sample.js
      └─ event
         ├─ example-a.json
         └─ example-b.json

@thim81 does look like something helping with your issue?

Yeah I like this solution, keeping the examples code in the one place, I will implement it and see how it feels and make sure it does not impact the other components. Thanks!

@thim81
Copy link
Contributor Author

thim81 commented Jun 21, 2022

Just thinking of this some more, once this in is place, it would be interesting to extend the asyncapi generator to dump the "examples" in the appropriate files.

@boyney123 boyney123 self-assigned this Jul 7, 2022
@boyney123 boyney123 added the enhancement New feature or request label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants