Skip to content

Commit 6d8955c

Browse files
authored
[Bug] Improve handling of response schemas and examples (#208)
* Handle examples as array and example as JSON * Comment out left padding * Refactor and move createExamples to createResponseSchema * Re-gen API docs * Only JSON.stringify() if typeof example equals object * Inherit tabItem height for mobile view from desktop styles
1 parent 21d3358 commit 6d8955c

33 files changed

+197
-248
lines changed

demo/docs/petstore/find-pets-by-status.api.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Multiple status values can be provided with comma separated strings
2727

2828
successful operation
2929

30-
</div><div><MimeTabs groupId={"mime-type"}><TabItem label={"application/json"} value={"application/json"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong><span style={{"opacity":"0.6"}}> array</span></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={undefined} schemaName={"object"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>category</strong><span style={{"opacity":"0.6"}}> Category</span></summary><div style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={"Category ID"} schemaName={"int64"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={false} schemaDescription={"Category name"} schemaName={"string"} qualifierMessage={"**Possible values:** `non-empty`"} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>sub</strong><span style={{"opacity":"0.6"}}> object</span></summary><div style={{"marginLeft":"1rem"}}><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>
30+
</div><div><MimeTabs groupId={"mime-type"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs groupId={"schema-tabs"}><TabTtem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong><span style={{"opacity":"0.6"}}> array</span></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={undefined} schemaName={"object"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>category</strong><span style={{"opacity":"0.6"}}> Category</span></summary><div style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={"Category ID"} schemaName={"int64"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={false} schemaDescription={"Category name"} schemaName={"string"} qualifierMessage={"**Possible values:** `non-empty`"} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>sub</strong><span style={{"opacity":"0.6"}}> object</span></summary><div style={{"marginLeft":"1rem"}}><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>
3131

3232
Test Sub Category
3333

@@ -47,7 +47,7 @@ Tags attached to the pet
4747

4848
Type of a pet
4949

50-
</div><DiscriminatorTabs><TabItem label={"cat"} value={"0-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"huntingSkill"} required={false} schemaDescription={"The measured skill for hunting"} schemaName={"string"} qualifierMessage={"**Possible values:** [`clueless`, `lazy`, `adventurous`, `aggressive`]"} defaultValue={"lazy"}></SchemaItem></div></TabItem><TabItem label={"dog"} value={"1-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"packSize"} required={false} schemaDescription={"The size of the pack the dog is from"} schemaName={"int32"} qualifierMessage={"**Possible values:** `>= 1`"} defaultValue={1}></SchemaItem></div></TabItem><TabItem label={"bee"} value={"2-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"honeyPerDay"} required={false} schemaDescription={"Average amount of honey produced per day in ounces"} schemaName={"number"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem></div></TabItem></DiscriminatorTabs></div></div></ul></details></TabItem><TabItem label={"application/xml"} value={"application/xml"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong><span style={{"opacity":"0.6"}}> array</span></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={undefined} schemaName={"object"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>category</strong><span style={{"opacity":"0.6"}}> Category</span></summary><div style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={"Category ID"} schemaName={"int64"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={false} schemaDescription={"Category name"} schemaName={"string"} qualifierMessage={"**Possible values:** `non-empty`"} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>sub</strong><span style={{"opacity":"0.6"}}> object</span></summary><div style={{"marginLeft":"1rem"}}><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>
50+
</div><DiscriminatorTabs><TabItem label={"cat"} value={"0-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"huntingSkill"} required={false} schemaDescription={"The measured skill for hunting"} schemaName={"string"} qualifierMessage={"**Possible values:** [`clueless`, `lazy`, `adventurous`, `aggressive`]"} defaultValue={"lazy"}></SchemaItem></div></TabItem><TabItem label={"dog"} value={"1-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"packSize"} required={false} schemaDescription={"The size of the pack the dog is from"} schemaName={"int32"} qualifierMessage={"**Possible values:** `>= 1`"} defaultValue={1}></SchemaItem></div></TabItem><TabItem label={"bee"} value={"2-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"honeyPerDay"} required={false} schemaDescription={"Average amount of honey produced per day in ounces"} schemaName={"number"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem></div></TabItem></DiscriminatorTabs></div></div></ul></details></TabTtem></SchemaTabs></TabItem><TabItem label={"application/xml"} value={"application/xml"}><SchemaTabs groupId={"schema-tabs"}><TabTtem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong><span style={{"opacity":"0.6"}}> array</span></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={undefined} schemaName={"object"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>category</strong><span style={{"opacity":"0.6"}}> Category</span></summary><div style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaDescription={"Category ID"} schemaName={"int64"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={false} schemaDescription={"Category name"} schemaName={"string"} qualifierMessage={"**Possible values:** `non-empty`"} defaultValue={undefined}></SchemaItem><SchemaItem collapsible={true} className={"schemaItem"}><details style={{}}><summary style={{}}><strong>sub</strong><span style={{"opacity":"0.6"}}> object</span></summary><div style={{"marginLeft":"1rem"}}><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>
5151

5252
Test Sub Category
5353

@@ -67,7 +67,7 @@ Tags attached to the pet
6767

6868
Type of a pet
6969

70-
</div><DiscriminatorTabs><TabItem label={"cat"} value={"0-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"huntingSkill"} required={false} schemaDescription={"The measured skill for hunting"} schemaName={"string"} qualifierMessage={"**Possible values:** [`clueless`, `lazy`, `adventurous`, `aggressive`]"} defaultValue={"lazy"}></SchemaItem></div></TabItem><TabItem label={"dog"} value={"1-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"packSize"} required={false} schemaDescription={"The size of the pack the dog is from"} schemaName={"int32"} qualifierMessage={"**Possible values:** `>= 1`"} defaultValue={1}></SchemaItem></div></TabItem><TabItem label={"bee"} value={"2-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"honeyPerDay"} required={false} schemaDescription={"Average amount of honey produced per day in ounces"} schemaName={"number"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem></div></TabItem></DiscriminatorTabs></div></div></ul></details></TabItem></MimeTabs></div></TabItem><TabItem label={"400"} value={"400"}><div>
70+
</div><DiscriminatorTabs><TabItem label={"cat"} value={"0-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"huntingSkill"} required={false} schemaDescription={"The measured skill for hunting"} schemaName={"string"} qualifierMessage={"**Possible values:** [`clueless`, `lazy`, `adventurous`, `aggressive`]"} defaultValue={"lazy"}></SchemaItem></div></TabItem><TabItem label={"dog"} value={"1-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"packSize"} required={false} schemaDescription={"The size of the pack the dog is from"} schemaName={"int32"} qualifierMessage={"**Possible values:** `>= 1`"} defaultValue={1}></SchemaItem></div></TabItem><TabItem label={"bee"} value={"2-item-discriminator"}><div style={{"marginLeft":"-4px"}}><SchemaItem collapsible={false} name={"honeyPerDay"} required={false} schemaDescription={"Average amount of honey produced per day in ounces"} schemaName={"number"} qualifierMessage={undefined} defaultValue={undefined}></SchemaItem></div></TabItem></DiscriminatorTabs></div></div></ul></details></TabTtem></SchemaTabs></TabItem></MimeTabs></div></TabItem><TabItem label={"400"} value={"400"}><div>
7171

7272
Invalid status value
7373

0 commit comments

Comments
 (0)