我有一个API的Swagger规范,如下所示:
swagger: '2.0'
info:
title: my-api
description: My API
version: v1
schemes:
- https
produces:
- application/json
paths:
v1/entry/check:
post:
...
v1/entry/enter:
post:
...
v1/exit/leave:
post:
...
...如您所见,paths中的每一条路径都以v1/作为前缀,因为规范描述了v1版本(也可以在info.version值中看到)。
我想知道,是否有一种方法可以避免重复这个前缀,即用v1/隐式地前缀所有路径?主要是,我想这样做,以避免任何意外误用规范,即完全防止添加另一个路径没有前缀。
发布于 2022-09-13 06:48:35
您可以将前缀指定为basePath。
basePath: /v1
paths:
/entry/check:
...
/entry/enter
...https://stackoverflow.com/questions/73697216
复制相似问题