Merge branch 'apidoc-use-element' into 'develop'
DEV: Use Elements to render API Document Co-authored-by: Lhcfl <Lhcfl@outlook.com> See merge request firefish/firefish!10891
This commit is contained in:
commit
a1373fd972
2 changed files with 14 additions and 18 deletions
|
@ -1,23 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>Firefish API</title>
|
||||
<!-- needed for adaptive design -->
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!--
|
||||
ReDoc doesn't change outer page styles
|
||||
-->
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<!-- Embed elements Elements via Web Component -->
|
||||
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<redoc spec-url="/api.json" expand-responses="200" expand-single-schema-field="true"></redoc>
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@2.0.0-rc.50/bundles/redoc.standalone.js" integrity="sha256-WJbngBWN9vp6vkEuzeoSj5tE5saW9Hfj6/SinkzhL2s=" crossorigin="anonymous"></script>
|
||||
<elements-api
|
||||
id="element-main"
|
||||
apiDescriptionUrl='/api.json'
|
||||
router="hash"
|
||||
layout="responsive"
|
||||
/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -101,7 +101,7 @@ export function genOpenapiSpec() {
|
|||
}
|
||||
|
||||
const info = {
|
||||
operationId: endpoint.name,
|
||||
operationId: `POST-${endpoint.name}`,
|
||||
summary: endpoint.name,
|
||||
description: desc,
|
||||
externalDocs: {
|
||||
|
@ -208,11 +208,11 @@ export function genOpenapiSpec() {
|
|||
},
|
||||
};
|
||||
|
||||
const path = {
|
||||
const path: Record<string, typeof info> = {
|
||||
post: info,
|
||||
};
|
||||
if (endpoint.meta.allowGet) {
|
||||
path.get = { ...info };
|
||||
path.get = { ...info, operationId: `GET-${endpoint.name}` };
|
||||
// API Key authentication is not permitted for GET requests
|
||||
path.get.security = path.get.security.filter(
|
||||
(elem) => !Object.prototype.hasOwnProperty.call(elem, "ApiKeyAuth"),
|
||||
|
|
Loading…
Reference in a new issue