mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
feat: add new demo file and improve test
This commit is contained in:
parent
d525e6d289
commit
456666eaa2
|
@ -5,7 +5,11 @@ import { resolve as urlResolve } from 'url';
|
||||||
import { RedocStandalone } from '../src';
|
import { RedocStandalone } from '../src';
|
||||||
import ComboBox from './ComboBox';
|
import ComboBox from './ComboBox';
|
||||||
|
|
||||||
|
const DEFAULT_SPEC = 'openapi.yaml';
|
||||||
|
const NEW_VERSION_SPEC = 'openapi-3-1.yaml';
|
||||||
|
|
||||||
const demos = [
|
const demos = [
|
||||||
|
{ value: NEW_VERSION_SPEC, label: 'OpenApi 3.1' },
|
||||||
{ value: 'https://api.apis.guru/v2/specs/instagram.com/1.0.0/swagger.yaml', label: 'Instagram' },
|
{ value: 'https://api.apis.guru/v2/specs/instagram.com/1.0.0/swagger.yaml', label: 'Instagram' },
|
||||||
{
|
{
|
||||||
value: 'https://api.apis.guru/v2/specs/googleapis.com/calendar/v3/openapi.yaml',
|
value: 'https://api.apis.guru/v2/specs/googleapis.com/calendar/v3/openapi.yaml',
|
||||||
|
@ -16,8 +20,6 @@ const demos = [
|
||||||
{ value: 'https://docs.graphhopper.com/openapi.json', label: 'GraphHopper' },
|
{ value: 'https://docs.graphhopper.com/openapi.json', label: 'GraphHopper' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEFAULT_SPEC = 'openapi.yaml';
|
|
||||||
|
|
||||||
class DemoApp extends React.Component<
|
class DemoApp extends React.Component<
|
||||||
{},
|
{},
|
||||||
{ specUrl: string; dropdownOpen: boolean; cors: boolean }
|
{ specUrl: string; dropdownOpen: boolean; cors: boolean }
|
||||||
|
@ -45,6 +47,9 @@ class DemoApp extends React.Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange = (url: string) => {
|
handleChange = (url: string) => {
|
||||||
|
if (url === NEW_VERSION_SPEC) {
|
||||||
|
this.setState({ cors: false })
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
specUrl: url,
|
specUrl: url,
|
||||||
});
|
});
|
||||||
|
|
1249
demo/openapi-3-1.yaml
Normal file
1249
demo/openapi-3-1.yaml
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
openapi: 3.1.0
|
openapi: 3.0.0
|
||||||
servers:
|
servers:
|
||||||
- url: //petstore.swagger.io/v2
|
- url: //petstore.swagger.io/v2
|
||||||
description: Default server
|
description: Default server
|
||||||
|
@ -42,7 +42,6 @@ info:
|
||||||
|
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
title: Swagger Petstore
|
title: Swagger Petstore
|
||||||
summary: My lovely API
|
|
||||||
termsOfService: 'http://swagger.io/terms/'
|
termsOfService: 'http://swagger.io/terms/'
|
||||||
contact:
|
contact:
|
||||||
name: API Support
|
name: API Support
|
||||||
|
@ -54,15 +53,12 @@ info:
|
||||||
license:
|
license:
|
||||||
name: Apache 2.0
|
name: Apache 2.0
|
||||||
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
||||||
identifier: Apache 2.0
|
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Find out how to create Github repo for your OpenAPI spec.
|
description: Find out how to create Github repo for your OpenAPI spec.
|
||||||
url: 'https://github.com/Rebilly/generator-openapi-repo'
|
url: 'https://github.com/Rebilly/generator-openapi-repo'
|
||||||
tags:
|
tags:
|
||||||
- name: pet
|
- name: pet
|
||||||
description: Everything about your Pets
|
description: Everything about your Pets
|
||||||
- name: webhooks
|
|
||||||
description: Everything about your Webhooks
|
|
||||||
- name: store
|
- name: store
|
||||||
description: Access to Petstore orders
|
description: Access to Petstore orders
|
||||||
- name: user
|
- name: user
|
||||||
|
@ -80,7 +76,6 @@ x-tagGroups:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
- store
|
- store
|
||||||
- webhooks
|
|
||||||
- name: User Management
|
- name: User Management
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
|
@ -898,38 +893,6 @@ paths:
|
||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
components:
|
components:
|
||||||
pathItems:
|
|
||||||
webhooks:
|
|
||||||
put:
|
|
||||||
summary: Get a cat details after update
|
|
||||||
description: Get a cat details after update
|
|
||||||
operationId: updatedCat
|
|
||||||
tags:
|
|
||||||
- webhooks
|
|
||||||
requestBody:
|
|
||||||
description: Information about cat in the system
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Cat"
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: update Cat details
|
|
||||||
post:
|
|
||||||
summary: Create new cat
|
|
||||||
description: Info about new cat
|
|
||||||
operationId: createdCat
|
|
||||||
tags:
|
|
||||||
- webhooks
|
|
||||||
requestBody:
|
|
||||||
description: Information about cat in the system
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Cat"
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: create Cat details
|
|
||||||
schemas:
|
schemas:
|
||||||
ApiResponse:
|
ApiResponse:
|
||||||
type: object
|
type: object
|
||||||
|
@ -1077,8 +1040,7 @@ components:
|
||||||
example: Guru
|
example: Guru
|
||||||
photoUrls:
|
photoUrls:
|
||||||
description: The list of URL to a cute photos featuring pet
|
description: The list of URL to a cute photos featuring pet
|
||||||
type: [string, integer, 'null', array]
|
type: array
|
||||||
minItems: 1
|
|
||||||
maxItems: 20
|
maxItems: 20
|
||||||
xml:
|
xml:
|
||||||
name: photoUrl
|
name: photoUrl
|
||||||
|
@ -1092,8 +1054,7 @@ components:
|
||||||
tags:
|
tags:
|
||||||
description: Tags attached to the pet
|
description: Tags attached to the pet
|
||||||
type: array
|
type: array
|
||||||
exclusiveMaximum: 100
|
minItems: 1
|
||||||
exclusiveMinimum: 0
|
|
||||||
xml:
|
xml:
|
||||||
name: tag
|
name: tag
|
||||||
wrapped: true
|
wrapped: true
|
||||||
|
@ -1106,7 +1067,6 @@ components:
|
||||||
- available
|
- available
|
||||||
- pending
|
- pending
|
||||||
- sold
|
- sold
|
||||||
default: pending
|
|
||||||
petType:
|
petType:
|
||||||
description: Type of a pet
|
description: Type of a pet
|
||||||
type: string
|
type: string
|
||||||
|
@ -1227,14 +1187,14 @@ components:
|
||||||
shipDate: '2018-10-19T16:46:45Z'
|
shipDate: '2018-10-19T16:46:45Z'
|
||||||
status: placed
|
status: placed
|
||||||
complete: false
|
complete: false
|
||||||
webhooks:
|
x-webhooks:
|
||||||
newPet:
|
newPet:
|
||||||
post:
|
post:
|
||||||
summary: New pet
|
summary: New pet
|
||||||
description: Information about a new pet in the systems
|
description: Information about a new pet in the systems
|
||||||
operationId: newPet
|
operationId: newPet
|
||||||
tags:
|
tags:
|
||||||
- webhooks
|
- pet
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
|
@ -1242,8 +1202,4 @@ webhooks:
|
||||||
$ref: "#/components/schemas/Pet"
|
$ref: "#/components/schemas/Pet"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Return a 200 status to indicate that the data was received successfully
|
description: Return a 200 status to indicate that the data was received successfully
|
||||||
myWebhook:
|
|
||||||
$ref: '#/components/pathItems/webhooks'
|
|
||||||
description: Overriding description
|
|
||||||
summary: Overriding summary
|
|
|
@ -6,7 +6,7 @@ describe('Menu', () => {
|
||||||
it('should have valid items count', () => {
|
it('should have valid items count', () => {
|
||||||
cy.get('.menu-content')
|
cy.get('.menu-content')
|
||||||
.find('li')
|
.find('li')
|
||||||
.should('have.length', 37);
|
.should('have.length', 34);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sync active menu items while scroll', () => {
|
it('should sync active menu items while scroll', () => {
|
||||||
|
|
|
@ -16,5 +16,6 @@ describe('Standalone bundle test', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
baseCheck('OAS3 mode', 'e2e/standalone.html');
|
baseCheck('OAS3 mode', 'e2e/standalone.html');
|
||||||
|
baseCheck('OAS3.1 mode', 'e2e/standalone-3-1.html');
|
||||||
baseCheck('OAS2 compatibility mode', 'e2e/standalone-compatibility.html');
|
baseCheck('OAS2 compatibility mode', 'e2e/standalone-compatibility.html');
|
||||||
});
|
});
|
||||||
|
|
8
e2e/standalone-3-1.html
Normal file
8
e2e/standalone-3-1.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<redoc spec-url="../demo/openapi-3-1.yaml" native-scrollbars></redoc>
|
||||||
|
<script src="../bundles/redoc.standalone.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
12
package-lock.json
generated
12
package-lock.json
generated
|
@ -1222,9 +1222,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@redocly/openapi-core": {
|
"@redocly/openapi-core": {
|
||||||
"version": "1.0.0-beta.46",
|
"version": "1.0.0-beta.48",
|
||||||
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.46.tgz",
|
"resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.0.0-beta.48.tgz",
|
||||||
"integrity": "sha512-w4VG2KNLFDuZgN7fBmbzbI0GJDiPnJ0SYszj4uuSkMW35SVTvDWyTaeWjW8ggQJ3gluDnTgUvm9tjLdR2tLqUg==",
|
"integrity": "sha512-rlus9qQC4Pkzz2Ljcv+jQjFdKOYSWnsYXWN6zNik9iiiQtMmGEdszsERCbSAYw/CZ5DRCAHMeKrh8f4LBCpx1A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@redocly/ajv": "^6.12.3",
|
"@redocly/ajv": "^6.12.3",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^14.11.8",
|
||||||
|
@ -1238,9 +1238,9 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "14.17.0",
|
"version": "14.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.1.tgz",
|
||||||
"integrity": "sha512-w8VZUN/f7SSbvVReb9SWp6cJFevxb4/nkG65yLAya//98WgocKm5PLDAtSs5CtJJJM+kHmJjO/6mmYW4MHShZA=="
|
"integrity": "sha512-/tpUyFD7meeooTRwl3sYlihx2BrJE7q9XF71EguPFIySj9B7qgnRtHsHTho+0AUm4m1SvWGm6uSncrR94q6Vtw=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -134,7 +134,7 @@
|
||||||
"styled-components": "^4.1.1 || ^5.1.1"
|
"styled-components": "^4.1.1 || ^5.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@redocly/openapi-core": "^1.0.0-beta.45",
|
"@redocly/openapi-core": "^1.0.0-beta.48",
|
||||||
"@redocly/react-dropdown-aria": "^2.0.11",
|
"@redocly/react-dropdown-aria": "^2.0.11",
|
||||||
"@types/node": "^13.11.1",
|
"@types/node": "^13.11.1",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
|
|
|
@ -63,4 +63,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ export class SchemaModel {
|
||||||
|
|
||||||
this.pointer = schemaOrRef.$ref || pointer || '';
|
this.pointer = schemaOrRef.$ref || pointer || '';
|
||||||
this.rawSchema = parser.deref(schemaOrRef);
|
this.rawSchema = parser.deref(schemaOrRef);
|
||||||
|
|
||||||
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
|
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
|
||||||
|
|
||||||
this.init(parser, isChild);
|
this.init(parser, isChild);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,12 @@ describe('#loadAndBundleSpec', () => {
|
||||||
expect(bundledSpec).toMatchSnapshot();
|
expect(bundledSpec).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should load And Bundle Spec demo/openapi-3-1.yaml', async () => {
|
||||||
|
const spec = yaml.load(readFileSync(resolve(__dirname, '../../../demo/openapi-3-1.yaml')));
|
||||||
|
const bundledSpec = await loadAndBundleSpec(spec);
|
||||||
|
expect(bundledSpec).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
it('should load And Bundle Spec demo/swagger.yaml', async () => {
|
it('should load And Bundle Spec demo/swagger.yaml', async () => {
|
||||||
const spec = yaml.load(readFileSync(resolve(__dirname, '../../../demo/swagger.yaml')));
|
const spec = yaml.load(readFileSync(resolve(__dirname, '../../../demo/swagger.yaml')));
|
||||||
const bundledSpec = await loadAndBundleSpec(spec);
|
const bundledSpec = await loadAndBundleSpec(spec);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user