Skip to content

Commit

Permalink
fix: no quotes for default values in header fields. (#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellrobinson authored and RomanHotsiy committed Oct 16, 2019
1 parent 8bfa364 commit b5af71d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion demo/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ x-tagGroups:
paths:
/pet:
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
in: cookie
description: Some cookie
Expand Down Expand Up @@ -678,6 +686,7 @@ components:
type: string
description: The measured skill for hunting
default: lazy
example: adventurous
enum:
- clueless
- lazy
Expand Down Expand Up @@ -890,7 +899,6 @@ components:
type: string
pattern: '/^\+(?:[0-9]-?){6,14}[0-9]$/'
example: +1-202-555-0192
nullable: true
userStatus:
description: User status
type: integer
Expand Down
6 changes: 4 additions & 2 deletions src/components/Fields/FieldDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class FieldDetails extends React.PureComponent<FieldProps> {

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;

if (showExamples && example !== undefined) {
Expand Down Expand Up @@ -59,15 +61,15 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
{schema.title && <TypeTitle> ({schema.title}) </TypeTitle>}
<ConstraintsView constraints={schema.constraints} />
{schema.nullable && <NullableLabel> {l('nullable')} </NullableLabel>}
{schema.pattern && <PatternLabel>{schema.pattern}</PatternLabel>}
{schema.pattern && <PatternLabel> {schema.pattern} </PatternLabel>}
{schema.isCircular && <RecursiveLabel> {l('recursive')} </RecursiveLabel>}
</div>
{deprecated && (
<div>
<Badge type="warning"> {l('deprecated')} </Badge>
</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} />}{' '}
{exampleField}
{<Extensions extensions={{ ...field.extensions, ...schema.extensions }} />}
Expand Down

0 comments on commit b5af71d

Please sign in to comment.