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 show the description when using the SchemaDefininition component #2611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

osamu329
Copy link

What/Why/How?

This change allows show the description of schema definition..
I choose default value of showDescription is false, because it keep current behavior for existing using of the component.

The PR solves #1840.

If set showDescription={true} in following code, schema description is shown in tag related schema.
The PR doesn't include the change in following code.
However I expect that schema description is rendered when x-tags is specified.

description: `<SchemaDefinition showWriteOnly={true} schemaRef="#/components/schemas/${schemaName}" />`,

Reference

Tests

Add some tests for SchemaDefinition.

Screenshots (optional)

image

OpenAPI spec for above screenshot
openapi: 3.1.0
info:
  title: SchemaDefinition showDescription demo.

tags:
  - name: Test1
    x-displayName: The Schema with description(showDescription=false)
    description: |
      <SchemaDefinition schemaRef="#/components/schemas/SchemaWithDescription" showExample={true} showDescription={false}/>
  - name: Test2
    x-displayName: The Schema with description(showDescription=true)
    description: |
      <SchemaDefinition schemaRef="#/components/schemas/SchemaWithDescription" showExample={false} showDescription={true}/>
  - name: Test3
    x-displayName: The Schema without description(showDescription=true)
    description: |
      <SchemaDefinition schemaRef="#/components/schemas/SchemaWithoutDescription" showExample={true} showDescription={true}/>

components:
  schemas:
    SchemaWithDescription:
      title: Schema with Description
      description: |
        ### Schema description

        ```js
        let pet = {id: "cat"}
        ```
      type: object
      properties:
        id:
          type: string

    SchemaWithoutDescription:
      title: Schema without description
      type: object
      properties:
        id:
          type: string

Check yourself

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

@osamu329 osamu329 requested a review from a team as a code owner October 27, 2024 13:56
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