问题
Having one big Swagger/OpenAPI YAML specification, how can I safely extract certain API endpoints and generate a new .yaml
for them exclusively?
It's easy to identify API endpoints from a certain level (like defined with one indent or more):
paths:
/users:
...
- $ref: '#/requests/getUser'
/repos:
...
requests:
getUser:
...
I'd just copy all sections, except paths
, into a new specs file. And then I'd copy certain paths
subsections like /users:
based on indents. In Python, with a regex.
But is this direct method safe for the specs?
回答1:
Swagger Inspector lets you make API calls and then create the definition file from them (letting you pick just a subset of calls like you want). See inspector.swagger.io - it's UI-based, but might save you some time.
来源:https://stackoverflow.com/questions/47590562/generate-a-swagger-file-for-certain-endpoints-from-another-swagger-or-openapi-fi