securitySchemesの定義を復活&ApiCallServiceの実装的にベアラトークンなのでその形で
This commit is contained in:
parent
2fd053058d
commit
b043aaa97c
|
|
@ -31,6 +31,13 @@ export function genOpenapiSpec(config: Config) {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
schemas: schemas,
|
schemas: schemas,
|
||||||
|
|
||||||
|
securitySchemes: {
|
||||||
|
bearerAuth: {
|
||||||
|
type: 'http',
|
||||||
|
scheme: 'bearer',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -61,21 +68,6 @@ export function genOpenapiSpec(config: Config) {
|
||||||
const requestType = endpoint.meta.requireFile ? 'multipart/form-data' : 'application/json';
|
const requestType = endpoint.meta.requireFile ? 'multipart/form-data' : 'application/json';
|
||||||
const schema = { ...endpoint.params };
|
const schema = { ...endpoint.params };
|
||||||
|
|
||||||
if (endpoint.meta.requireCredential) {
|
|
||||||
// https://swagger.io/docs/specification/authentication/api-keys/
|
|
||||||
// ↑曰く、「can be "header", "query" or "cookie"」とのこと。
|
|
||||||
// Misskeyはbodyに埋め込む形にしているので、各エンドポイントのパラメータに直接APIキー用のフィールドを追加する必要がある
|
|
||||||
schema.properties = {
|
|
||||||
'i': {
|
|
||||||
type: 'string',
|
|
||||||
nullable: false,
|
|
||||||
description: 'API Key',
|
|
||||||
},
|
|
||||||
...schema.properties,
|
|
||||||
};
|
|
||||||
schema.required = ['i', ...schema.required ?? []];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endpoint.meta.requireFile) {
|
if (endpoint.meta.requireFile) {
|
||||||
schema.properties = {
|
schema.properties = {
|
||||||
...schema.properties,
|
...schema.properties,
|
||||||
|
|
@ -104,6 +96,11 @@ export function genOpenapiSpec(config: Config) {
|
||||||
...(endpoint.meta.tags ? {
|
...(endpoint.meta.tags ? {
|
||||||
tags: [endpoint.meta.tags[0]],
|
tags: [endpoint.meta.tags[0]],
|
||||||
} : {}),
|
} : {}),
|
||||||
|
...(endpoint.meta.requireCredential ? {
|
||||||
|
security: [{
|
||||||
|
bearerAuth: [],
|
||||||
|
}],
|
||||||
|
} : {}),
|
||||||
requestBody: {
|
requestBody: {
|
||||||
required: true,
|
required: true,
|
||||||
content: {
|
content: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue