-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: referenced header name is empty
- Loading branch information
1 parent
e1b2065
commit 13165fb
Showing
3 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"version": "1.0", | ||
"title": "Foo" | ||
}, | ||
"components": { | ||
"parameters": { | ||
"testParam": { | ||
"in": "path", | ||
"name": "test_name", | ||
"schema": { "type": "string" } | ||
} | ||
}, | ||
"headers": { | ||
"testHeader": { | ||
"description": "The response content language", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { FieldModel } from '../../models/Field'; | ||
import { OpenAPIParser } from '../../OpenAPIParser'; | ||
import { RedocNormalizedOptions } from '../../RedocNormalizedOptions'; | ||
|
||
const opts = new RedocNormalizedOptions({}); | ||
|
||
describe('Models', () => { | ||
describe('FieldModel', () => { | ||
let parser; | ||
const spec = require('../fixtures/fields.json'); | ||
parser = new OpenAPIParser(spec, undefined, opts); | ||
|
||
test('basic field details', () => { | ||
const field = new FieldModel( | ||
parser, | ||
{ | ||
$ref: '#/components/parameters/testParam', | ||
}, | ||
'#/components/parameters/testParam', | ||
opts, | ||
); | ||
|
||
expect(field.name).toEqual('test_name'); | ||
expect(field.in).toEqual('path'); | ||
expect(field.required).toEqual(false); | ||
expect(field.schema.type).toEqual('string'); | ||
}); | ||
|
||
test('field name should populated from name even if $ref (headers)', () => { | ||
const field = new FieldModel( | ||
parser, | ||
{ | ||
$ref: '#/components/headers/testHeader', | ||
name: 'Test-Header', | ||
}, | ||
'#/components/headers/testHeader', | ||
opts, | ||
); | ||
|
||
expect(field.name).toEqual('Test-Header'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters