这是我的 openapi yaml 文件。我正在使用 express-openapi-validator 包。
openapi: '3.0.0'
info:
version: 1.0.0
title: Swagger Learn-Ops
description: Learn Ops api
termsOfService: http://swagger.io/terms/
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
paths:
/user:
get:
summary: List
operationId: listUsers
description: List all Users
tags:
- users
responses:
200:
description: A paged array of users
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/UserResponse'
default:
description: default error message
$ref: '#/components/schemas/Error'
components:
parameters:
id:
name: id
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
limit:
name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
schemas:
UserResponse:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
在我的控制器中,即使我通过字符串发送验证器也不会抛出我期望的错误消息。 有人可以告诉我我错过了什么..
控制器操作目前只有这一行代码。
return response.status(200).send('hello world 5656')