Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jfoclpf/get-openapi-examples
Extract all possible paths present in openapi.yaml based on paths and the provided examples
https://github.com/jfoclpf/get-openapi-examples
openapi openapi-spec openapi-specification openapi3
Last synced: about 1 month ago
JSON representation
Extract all possible paths present in openapi.yaml based on paths and the provided examples
- Host: GitHub
- URL: https://github.com/jfoclpf/get-openapi-examples
- Owner: jfoclpf
- Created: 2024-05-19T19:27:47.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-20T17:55:34.000Z (6 months ago)
- Last Synced: 2024-10-01T06:43:57.544Z (about 2 months ago)
- Topics: openapi, openapi-spec, openapi-specification, openapi3
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## get-openapi-examples
### Extract all possible paths present in `openapi.yaml` based on paths and the provided examplesThis might be useful, for example, for testing routes. It supports different types of [examples](https://swagger.io/docs/specification/adding-examples/), and variables may be in the path or in the query.
If you have a `openapi.yaml` file like this one, for example:
```yaml
paths:
/coordinates:
get:
operationId: getDataByCoordinates
summary: Get data by Coordinates in query
parameters:
- in: query
name: lat
schema:
type: string
example: '40.153687'
description: Latitude of the point
- in: query
name: lon
schema:
type: string
example: '-8.514602'
description: Longitude of the point/district/{district}:
get:
operationId: getDistrict
summary: Data of Distrito
parameters:
- in: path
name: district
required: true
schema:
type: string
examples:
porto:
value: Porto
summary: District of Porto
lisbon:
value: Lisbon
summary: District of Lisbon/district/{district}/altimetry:
get:
operationId: getDistrictAltimetry
summary: Altimetry of Distrito
parameters:
- in: path
name: district
required: true
schema:
type: string
example: Porto
```Then:
```js
const getOpenapiExamples = require('get-openapi-examples')
console.log(getOpenapiExamples('/path/to/openapi.yaml'))
/*
[
'/coordinates?lat=40.153687&lon=-8.514602',
'/district/Porto',
'/district/Lisbon',
'/district/Porto/altimetry'
}
*/```