import { MediaType, Method } from '../common'; import { Schema } from '../schema'; /** * @see https://swagger.io/docs/specification/2-0/describing-parameters/ */ export type Paths = Record>; export type ParameterLocation = 'query' | 'path' | 'body'; export interface OperationMetadata { operationId: string; /** 当前接口说明 */ summary: string; /** 参数列表 */ parameters: Parameter[]; /** 接口标签,作为api分类用,多个分类将转成字符串 */ tags: string[]; /** 请求携带的参数 */ requestBody?: RequestBody; /** api返回值 */ responses: Responses; } export interface Parameter { /** 参数字段名称 */ name: string; /** 参数位置 */ in: ParameterLocation; /** 参数详细定义 */ schema: Schema; /** * query 参数类型 比如string、number */ type: string; /** * 数据类型,eg: int32,date-time */ format: string; /** * 是否为必填 * @default false */ required?: boolean; /** 参数描述 */ description?: string; /** * 允许无值,只有字段的情况 * @example GET /foo?metadata */ allowEmptyValue?: boolean; /** 案例 */ examples?: object; /** 废弃 */ deprecated?: boolean; } export type RequestBody = RequestBodyObject | RequestBodyRef; export interface RequestBodyObject { content?: BodyObjectContent; /** body 的描述 */ description?: string; /** body 是否可选 */ required?: boolean; } export interface RequestBodyRef { $ref: `#/components/requestBodies/${string}`; } export type BodyObjectContent = Partial>; export interface Responses { 200?: { description: string; schema: Schema; }; [k: string]: any; }