What is the way to handle Swagger operationId value for default and versioned endpoint when the same endpoint is reused?

自古美人都是妖i 提交于 2020-01-16 08:05:27

问题


Swagger requires that the operationId value be unique for each endpoint.

However, if I have an endpoint that is shared by both default (http://localhost/endpoint_name) and the versioned endpoint (http://localhost/v1/endpoint_name), then how do I handle the swaggger for this?

If I set the operationId to any value, then it will get replicated for both the endpoints and it gives me an error due to reuse of the same operationId.


回答1:


OpenAPI V3 allows you to specify multiple URLs.

e.g.

openapi: 3.0.3
info:
  title: TestAPI
  version: 1.0.0
servers:
- url: 'http://localhost/endpoint_name'
- url: 'http://localhost/v1/endpoint_name'
paths: {}


来源:https://stackoverflow.com/questions/59675490/what-is-the-way-to-handle-swagger-operationid-value-for-default-and-versioned-en

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!