fix: no quotes for default values in header fields. (#1059)

This commit is contained in:
russellrobinson 2019-10-17 00:01:54 +11:00 committed by Roman Hotsiy
parent 8bfa364010
commit b5af71da5f
2 changed files with 13 additions and 3 deletions

View File

@ -86,6 +86,14 @@ x-tagGroups:
paths: paths:
/pet: /pet:
parameters: parameters:
- name: Accept-Language
in: header
description: "The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US"
example: en-US
required: false
schema:
type: string
default: en-AU
- name: cookieParam - name: cookieParam
in: cookie in: cookie
description: Some cookie description: Some cookie
@ -678,6 +686,7 @@ components:
type: string type: string
description: The measured skill for hunting description: The measured skill for hunting
default: lazy default: lazy
example: adventurous
enum: enum:
- clueless - clueless
- lazy - lazy
@ -890,7 +899,6 @@ components:
type: string type: string
pattern: '/^\+(?:[0-9]-?){6,14}[0-9]$/' pattern: '/^\+(?:[0-9]-?){6,14}[0-9]$/'
example: +1-202-555-0192 example: +1-202-555-0192
nullable: true
userStatus: userStatus:
description: User status description: User status
type: integer type: integer

View File

@ -31,6 +31,8 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
const { schema, description, example, deprecated } = field; const { schema, description, example, deprecated } = field;
const rawDefault = !!enumSkipQuotes || field.in === 'header'; // having quotes around header field default values is confusing and inappropriate
let exampleField: JSX.Element | null = null; let exampleField: JSX.Element | null = null;
if (showExamples && example !== undefined) { if (showExamples && example !== undefined) {
@ -59,7 +61,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
{schema.title && <TypeTitle> ({schema.title}) </TypeTitle>} {schema.title && <TypeTitle> ({schema.title}) </TypeTitle>}
<ConstraintsView constraints={schema.constraints} /> <ConstraintsView constraints={schema.constraints} />
{schema.nullable && <NullableLabel> {l('nullable')} </NullableLabel>} {schema.nullable && <NullableLabel> {l('nullable')} </NullableLabel>}
{schema.pattern && <PatternLabel>{schema.pattern}</PatternLabel>} {schema.pattern && <PatternLabel> {schema.pattern} </PatternLabel>}
{schema.isCircular && <RecursiveLabel> {l('recursive')} </RecursiveLabel>} {schema.isCircular && <RecursiveLabel> {l('recursive')} </RecursiveLabel>}
</div> </div>
{deprecated && ( {deprecated && (
@ -67,7 +69,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
<Badge type="warning"> {l('deprecated')} </Badge> <Badge type="warning"> {l('deprecated')} </Badge>
</div> </div>
)} )}
<FieldDetail raw={enumSkipQuotes} label={l('default') + ':'} value={schema.default} /> <FieldDetail raw={rawDefault} label={l('default') + ':'} value={schema.default} />
{!renderDiscriminatorSwitch && <EnumValues type={schema.type} values={schema.enum} />}{' '} {!renderDiscriminatorSwitch && <EnumValues type={schema.type} values={schema.enum} />}{' '}
{exampleField} {exampleField}
{<Extensions extensions={{ ...field.extensions, ...schema.extensions }} />} {<Extensions extensions={{ ...field.extensions, ...schema.extensions }} />}