-
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.
- Loading branch information
1 parent
ee822f6
commit ff3bb24
Showing
3 changed files
with
88 additions
and
2 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,67 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"servers": [], | ||
"info": { | ||
"title": "Broken Redoc Discriminator", | ||
"version": "" | ||
}, | ||
"paths": { | ||
"/foo": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"$ref": "#/components/schemas/FooTopLevel" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"JsonApiResource": { | ||
"type": "object", | ||
"description": "A related resource.", | ||
"required": [ | ||
"type" | ||
], | ||
"discriminator": { | ||
"propertyName": "type" | ||
}, | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"description": "The type of object this resource represents." | ||
} | ||
} | ||
}, | ||
"FooTopLevel": { | ||
"type": "object", | ||
"required": [ | ||
"data" | ||
], | ||
"properties": { | ||
"data": { | ||
"$ref": "#/components/schemas/Foo" | ||
} | ||
} | ||
}, | ||
"Foo": { | ||
"allOf": [ | ||
{ | ||
"type": "object" | ||
}, | ||
{ | ||
"$ref": "#/components/schemas/JsonApiResource" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
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,19 @@ | ||
import { SchemaModel } from '../../models/Schema'; | ||
import { OpenAPIParser } from '../../OpenAPIParser'; | ||
import { RedocNormalizedOptions } from '../../RedocNormalizedOptions'; | ||
|
||
const opts = new RedocNormalizedOptions({}); | ||
|
||
describe('Models', () => { | ||
describe('Schema', () => { | ||
let parser; | ||
|
||
test('discriminator with one field', () => { | ||
const spec = require('../fixtures/discriminator.json'); | ||
parser = new OpenAPIParser(spec, undefined, opts); | ||
const schema = new SchemaModel(parser, spec.components.schemas.Foo, '', opts); | ||
expect(schema.oneOf).toHaveLength(1); | ||
expect(schema.discriminatorProp).toEqual('type'); | ||
}); | ||
}); | ||
}); |
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