Update open api script

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-10-27 14:24:09 +01:00
parent 487b872210
commit cdefc1d2de
5 changed files with 122 additions and 54 deletions

View File

@ -73,7 +73,7 @@
"test:e2e": "FORCE_COLOR=true jest --config jest.config.e2e.js --runInBand --verbose --forceExit --detectOpenHandles",
"test:generate-app": "node test/createTestApp.js",
"test:start-app": "node test/startTestApp.js",
"doc:api": "node scripts/serve-package-oas.js"
"doc:api": "node scripts/open-api/serve.js"
},
"author": {
"email": "hi@strapi.io",

View File

@ -52,7 +52,7 @@
{
"method": "POST",
"path": "/explorer/uid/generate",
"path": "/uid/generate",
"handler": "ContentManager.generateUID",
"config": {
"policies": []
@ -60,7 +60,7 @@
},
{
"method": "POST",
"path": "/explorer/uid/check-availability",
"path": "/uid/check-availability",
"handler": "ContentManager.checkUIDAvailability",
"config": {
"policies": []

View File

@ -44,17 +44,14 @@ paths:
type: object
token:
type: string
/content-manager/content-types:
get:
tags:
- ContentTypes
description: List content types
parameters:
- in: query
name: kind
schema:
$ref: '#/components/parameters/kind'
description: The number of items to skip before starting to collect the result set
- $ref: '#/components/parameters/kind'
responses:
200:
description: A list of content types
@ -194,6 +191,80 @@ paths:
data:
$ref: '#/components/schemas/component-configuration'
/content-manager/uid/generate:
post:
tags:
- UID attribute utils
description: Generate a uid
/content-manager/uid/check-availability:
post:
tags:
- UID attribute utils
description: Check availability of a uid
/content-manager/relationships/{modelUid}/{targetField}:
get:
tags:
- Relational fields
description: Fetch list of possible related content
/content-manager/collection-type/{modelUid}:
get:
tags:
- Collection Types content management
description: Get a list of entries
post:
tags:
- Collection Types content management
description: Create an entry
/content-manager/collection-type/{modelUid}/actions/bulkDelete:
post:
tags:
- Collection Types content management
description: Bulk delete entries
/content-manager/collection-type/{modelUid}/{id}:
get:
tags:
- Collection Types content management
description: Get one entry
put:
tags:
- Collection Types content management
description: Update one entry
delete:
tags:
- Collection Types content management
description: Delete one entry
/content-manager/collection-type/{modelUid}/{id}/actions/publish:
post:
tags:
- Collection Types content management
description: Publish one entry
/content-manager/collection-type/{modelUid}/{id}/actions/unpublish:
post:
tags:
- Collection Types content management
description: Unpublish one entry
/content-manager/single-type/{modelUid}:
get:
tags:
- Single Types content management
put:
tags:
- Single Types content management
delete:
tags:
- Single Types content management
/content-manager/single-type/{modelUid}/actions/publish:
post:
tags:
- Single Types content management
/content-manager/single-type/{modelUid}/actions/unpublish:
post:
tags:
- Single Types content management
components:
schemas:
contentType:
@ -203,7 +274,7 @@ components:
type: string
description: Model uid
kind:
$ref: '#/components/parameters/kind'
$ref: '#/components/schemas/kind'
isDisplayed:
type: boolean
apiID:
@ -332,6 +403,12 @@ components:
type: boolean
- $ref: '#/components/schemas/configuration'
kind:
type: string
enum:
- singleType
- collectionType
examples:
restaurant:
uid: application::restaurant.restaurant
@ -362,10 +439,11 @@ components:
parameters:
kind:
type: string
enum:
- singleType
- collectionType
in: query
name: kind
schema:
$ref: '#/components/schemas/kind'
description: The number of items to skip before starting to collect the result set
securitySchemes:
bearerAuth:

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet" />
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
</head>
<body>
<rapi-doc
spec-url="/spec.yml"
allow-server-selection="false"
show-header="false"
regular-font="Nunito"
bg-color="#2B303B"
text-color="#dee3ec"
nav-bg-color=""
nav-text-color=""
nav-hover-bg-color=""
nav-hover-text-color=""
nav-accent-color=""
primary-color=""
theme="dark"
schema-style="table"
>
</rapi-doc>
</body>
</html>

View File

@ -18,19 +18,18 @@ if (!args[0]) {
async function run() {
const app = new koa();
const openAPISpecPath = path.join(__dirname, '../packages', args[0], 'oas.yml');
const openAPISpecPath = path.join(__dirname, '../../packages', args[0], 'oas.yml');
if (!(await fse.pathExists(openAPISpecPath))) {
throw new Error(`No OAS configuration found at ${openAPISpecPath}`);
}
app.use(koaStatic(path.join(__dirname, 'public')));
app.use(ctx => {
if (ctx.path === '/spec.yml') {
ctx.body = fse.createReadStream(openAPISpecPath);
return;
}
ctx.body = indexPage;
});
const port = await getPort({ port: 1339 });
@ -44,40 +43,3 @@ run().catch(error => {
console.log('Unexpected Error:', error);
process.exit(1);
});
const indexPage = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link
href="https://fonts.googleapis.com/css?family=Nunito"
rel="stylesheet"
/>
<script
type="module"
src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"
></script>
</head>
<body>
<rapi-doc
spec-url="/spec.yml"
allow-server-selection="false"
show-header="false"
regular-font="Nunito"
bg-color="#2B303B"
text-color="#dee3ec"
nav-bg-color=""
nav-text-color=""
nav-hover-bg-color=""
nav-hover-text-color=""
nav-accent-color=""
primary-color=""
theme="dark"
render-style="focused"
schema-style="table"
>
</rapi-doc>
</body>
</html>
`;