-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Showing
393 changed files
with
22,972 additions
and
3,397 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,60 @@ | ||
import * as fs from 'fs'; | ||
import { App, createPage, Page } from '@vuepress/core'; | ||
import glob from 'glob'; | ||
import JSON5 from 'json5'; | ||
const merge = require('deepmerge') | ||
var getDirName = require('path').dirname; | ||
|
||
const combineMerge = (target, source, options) => { | ||
const destination = target.slice() | ||
|
||
source.forEach((item, index) => { | ||
if (typeof destination[index] === 'undefined') { | ||
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options) | ||
} else if (options.isMergeableObject(item)) { | ||
destination[index] = merge(target[index], item, options) | ||
} else if (target.indexOf(item) === -1) { | ||
destination.push(item) | ||
} | ||
}) | ||
return destination | ||
} | ||
|
||
const openApiDefinition = JSON.parse(fs.readFileSync(__dirname + '/api.json', 'utf8')); | ||
const endpointPaths = Object.keys(openApiDefinition.paths); | ||
const endpointTags = Array.from(new Set(Object.values(openApiDefinition.paths).flatMap(x => x.post.tags ?? []))); | ||
|
||
function writeFile(path, contents, cb) { | ||
fs.mkdir(getDirName(path), { recursive: true}, function (err) { | ||
fs.writeFileSync(path, contents); | ||
}); | ||
} | ||
|
||
export async function generateEndpointPages(app: App) { | ||
for (const endpointPath of endpointPaths) { | ||
const name = endpointPath.substring(1); | ||
const def = openApiDefinition.paths[endpointPath]['post']; | ||
const requireCredential = def.security?.length > 0; | ||
const errors = {}; | ||
for (const e of Object.keys(def.responses['400']?.content['application/json'].examples)) { | ||
const err = def.responses['400']?.content['application/json'].examples[e].value.error; | ||
if (err.id === '3d81ceae-475f-4600-b2a8-2bc116157532') continue; // INVALID_PARAMは全API共通なため | ||
errors[err.id] = { | ||
id: err.id, | ||
code: err.code, | ||
description: '', | ||
}; | ||
} | ||
const data = { | ||
summary: '', | ||
description: '', | ||
tags: def.tags, | ||
requireCredential, | ||
req: def.requestBody.content['application/json']?.schema ?? {}, | ||
res: def.responses['200']?.content['application/json'].schema ?? {}, | ||
errors, | ||
}; | ||
|
||
writeFile(__dirname + `/_api_/${name}.json5`, JSON5.stringify(data, null, '\t'), 'utf8'); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
{} |
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,104 @@ | ||
{ | ||
paths: { | ||
'/ping': { | ||
post: { | ||
summary: '接続確認を行います。', | ||
description: '接続確認を行います。', | ||
responses: { | ||
'200': { | ||
content: { | ||
'application/json': { | ||
schema: { | ||
properties: { | ||
pong: { | ||
description: 'レスポンス時の時刻です。', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
'/notes': { | ||
post: { | ||
summary: 'ノート一覧を取得します。', | ||
description: 'ノート一覧を取得します。', | ||
requestBody: { | ||
content: { | ||
'application/json': { | ||
schema: { | ||
properties: { | ||
local: { | ||
description: 'ローカルで作成されたノートのみを取得します。', | ||
}, | ||
reply: { | ||
description: '`true` にすると返信だけを、 `false` にすると返信以外を取得します。値を設定しなければ返信であるかそうでないかに関係なくノートを取得します。', | ||
}, | ||
renote: { | ||
description: '`true` にするとリノートだけを、 `false` にするとリノート以外を取得します。値を設定しなければリノートであるかそうでないかに関係なくノートを取得します。', | ||
}, | ||
withFiles: { | ||
description: '`true` にすると添付ファイルのあるノートだけを、 `false` にすると添付ファイルがないノートだけを取得します。値を設定しなければ添付ファイルの有無にかかわらずノートを取得します。', | ||
}, | ||
poll: { | ||
description: '`true` にすると投票を含むノートだけを、 `false` にすると含まないノートだけを取得します。値を設定しなければ投票の有無にかかわらずノートを取得します。', | ||
}, | ||
limit: { | ||
description: '取得するノートの最大数を指定します。', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
'/get-online-users-count': { | ||
post: { | ||
summary: 'オンラインになっているユーザ数を取得します。', | ||
description: 'オンラインになっているユーザ数を取得します。', | ||
responses: { | ||
'200': { | ||
content: { | ||
'application/json': { | ||
schema: { | ||
properties: { | ||
count: { | ||
description: '現在オンライン(10分以内に何らかのアクションをとった)であるユーザ数です。', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
'/i/pin': { | ||
post: { | ||
summary: 'ノートをピン留めします。', | ||
description: 'ノートをピン留めします。ピン留めされたノートはMisskey Webのプロフィールページに表示されたりします。', | ||
}, | ||
}, | ||
'/i/unpin': { | ||
post: { | ||
summary: 'ノートをピン留めから解除します。', | ||
description: 'ノートをピン留めから解除します。', | ||
}, | ||
}, | ||
'/clips/create': { | ||
post: { | ||
summary: 'クリップを作成します。', | ||
description: 'クリップを作成します。', | ||
}, | ||
}, | ||
'/clips/list': { | ||
post: { | ||
summary: '自分のクリップの一覧を取得します。', | ||
description: '自分のクリップの一覧を取得します。', | ||
}, | ||
}, | ||
}, | ||
} |
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,8 @@ | ||
import { defineClientConfig } from '@vuepress/client' | ||
import ElementPlus from 'element-plus' | ||
|
||
export default defineClientConfig({ | ||
enhance({app, router, siteData}) { | ||
app.use(ElementPlus, { }) | ||
}, | ||
}) |
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
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,45 @@ | ||
<template> | ||
<div class="mk-api-errors"> | ||
<el-tabs v-model="activeName"> | ||
<el-tab-pane label="固有のエラー" name="a"> | ||
<template v-if="Object.keys(errors).length > 0"> | ||
<el-collapse v-model="expands"> | ||
<el-collapse-item v-for="e in errors" :title="e.code" :name="e.id"> | ||
<div>{{ e.description }}</div> | ||
<div class="_mono">ID: {{ e.id }}</div> | ||
</el-collapse-item> | ||
</el-collapse> | ||
</template> | ||
<template v-else> | ||
<el-alert title="なし" type="success" :closable="false" /> | ||
</template> | ||
</el-tab-pane> | ||
<el-tab-pane label="共通のエラー" name="b"> | ||
<el-collapse v-model="commonExpands"> | ||
<el-collapse-item v-for="e in commonErrors" :title="e.code" :name="e.id"> | ||
<div>{{ e.description }}</div> | ||
<div class="_mono">ID: {{ e.id }}</div> | ||
</el-collapse-item> | ||
</el-collapse> | ||
</el-tab-pane> | ||
</el-tabs> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, watch } from 'vue'; | ||
import JSON5 from 'json5'; | ||
const props = defineProps<{ | ||
errors: any[]; | ||
commonErrors: any[]; | ||
}>(); | ||
const activeName = ref('a') | ||
const expands = ref([]); | ||
const commonExpands = ref([]); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> |
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,23 @@ | ||
<template> | ||
<div class="mk-api-resources"> | ||
<el-collapse v-model="expands"> | ||
<el-collapse-item title="Definition" name="definition"> | ||
{{ def }} | ||
</el-collapse-item> | ||
</el-collapse> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { ref, watch } from 'vue'; | ||
import JSON5 from 'json5'; | ||
const props = defineProps<{ | ||
def: any; | ||
}>(); | ||
const expands = ref([]); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> |
Oops, something went wrong.