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: add option to hide the example code when using the SchemaDefinition component #2157

Merged

Conversation

andre-stoesel
Copy link
Contributor

What/Why/How?

This change allows hiding the examples of a schema definition.

This is useful if the schema is not part of the API but an external resource like a configuration file. As these may have to be created in a different format, a json example would only confuse the user.

Reference

Testing

Screenshots (optional)

Check yourself

  • Code is linted
  • Tested
  • All new/updated code is covered with tests

@andre-stoesel andre-stoesel requested a review from a team as a code owner September 7, 2022 08:36
@andre-stoesel andre-stoesel requested review from AlexVarchuk and removed request for a team September 7, 2022 08:36
@AlexVarchuk
Copy link
Collaborator

Hi @andre-stoesel, thanks for your contribution. Can you add some examples of usage(definition) and screenshots for it?

@andre-stoesel
Copy link
Contributor Author

Hi @andre-stoesel, thanks for your contribution. Can you add some examples of usage(definition) and screenshots for it?

An example is one of our web services. (Unfortunately the documentation is not finished and approved yet, so I can't link it here).
We document not only the API with redoc, but also the steps necessary for the installation and setup of the web service.
For this we simply create a tag with an appropriate description and use the SchemaDefinition component in markdown.
Similar as it is done in the demo/openapi.yaml file with the tag pet_model.

In our case the schema to be displayed corresponds to a configuration file in XML format. Since the SchemaDefinition component as far as I know only displays json as an example, we would rather hide this.

Changing the pet_model tag leads to the following result:

  - name: pet_model
    x-displayName: The Pet Model
    description: |
      <SchemaDefinition schemaRef="#/components/schemas/Pet" showExample={false} />

image

As you can see, the example in the gray right side of the page is not displayed.

@AlexVarchuk AlexVarchuk merged commit 168189b into Redocly:main Sep 19, 2022
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

Successfully merging this pull request may close these issues.

2 participants