Skip to content

Commit

Permalink
refactor: break down OpenApi spec into multiple files (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKolarik authored Sep 21, 2023
1 parent 3121388 commit 03edd29
Show file tree
Hide file tree
Showing 12 changed files with 19,391 additions and 14,278 deletions.
29,868 changes: 17,472 additions & 12,396 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@koa/router": "^12.0.0",
"@maxmind/geoip2-node": "^3.5.0",
"@redocly/openapi-core": "^1.2.0",
"@socket.io/redis-adapter": "^8.1.0",
"adm-zip": "^0.5.10",
"any-ascii": "^0.3.2",
Expand Down Expand Up @@ -44,6 +45,7 @@
"@apideck/portman": "^1.22.0",
"@apidevtools/swagger-parser": "^10.1.0",
"@martin-kolarik/eslint-config": "^7.1.6",
"@redocly/cli": "^1.2.0",
"@stoplight/spectral-cli": "^6.6.0",
"@tsconfig/node18-strictest-esm": "^1.0.1",
"@types/adm-zip": "^0.5.0",
Expand Down Expand Up @@ -126,7 +128,7 @@
"test:mocha:dev": "TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test FAKE_PROBE_IP=api NEW_RELIC_ENABLED=false NEW_RELIC_LOG_ENABLED=false mocha",
"test:perf": "tsx test-perf/index.ts",
"test:portman": "TEST_DONT_RESTART_WORKERS=1 start-test 'npm run start:test' http://localhost:3000/health 'npm run test:portman:create && npm run test:portman:run' 2> /dev/null || E=$?; rm -rf tmp; exit $E;",
"test:portman:create": "portman --cliOptionsFile test/tests/contract/portman-cli.json",
"test:portman:create": "mkdir -p tmp && redocly bundle public/v1/spec.yaml > tmp/spec.yaml && portman --cliOptionsFile test/tests/contract/portman-cli.json",
"test:portman:run": "newman run tmp/converted/globalpingApi.json -e test/tests/contract/newman-env.json --ignore-redirects"
},
"lint-staged": {
Expand Down
482 changes: 482 additions & 0 deletions public/v1/components/examples.yaml

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions public/v1/components/headers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
components:
headers:
MeasurementLocation:
description: A link to the newly created measurement.
schema:
type: string
format: uri
RateLimitLimit:
description: The number of requests available in a given time window.
schema:
type: integer
RateLimitRemaining:
description: The number of requests remaining in the current time window.
schema:
type: integer
RateLimitReset:
description: The number of seconds until the limit is reset.
schema:
type: integer
8 changes: 8 additions & 0 deletions public/v1/components/parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
components:
parameters:
measurementId:
in: path
name: id
required: true
schema:
type: string
157 changes: 157 additions & 0 deletions public/v1/components/responses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
components:
responses:
'400':
description: Bad Request
content:
application/json:
schema:
type: object
required:
- error
properties:
error:
type: object
required:
- type
- message
properties:
type:
type: string
message:
type: string
params:
type: object
additionalProperties:
type: string
examples:
json:
value:
error:
type: validation_error
message: Parameter validation failed.
params:
measurement: '\"measurement\" does not match any of the allowed types'
'404':
description: Not Found
content:
application/json:
schema:
type: object
required:
- error
properties:
error:
type: object
required:
- type
- message
properties:
type:
type: string
message:
type: string
examples:
json:
value:
error:
type: not_found
message: Couldn't find the requested item.
measurements422:
description: Unprocessable Entity
content:
application/json:
schema:
type: object
required:
- error
properties:
error:
type: object
required:
- type
- message
properties:
type:
type: string
message:
type: string
examples:
json:
value:
error:
type: no_probes_found
message: No suitable probes found.
measurements429:
description: Too Many Requests
content:
application/json:
schema:
type: object
required:
- error
properties:
error:
type: object
required:
- type
- message
properties:
type:
type: string
message:
type: string
examples:
json:
value:
error:
type: rate_limit_exceeded
message: API rate limit exceeded.
measurements202:
description: Accepted
headers:
Location:
$ref: 'headers.yaml#/components/headers/MeasurementLocation'
X-RateLimit-Limit:
$ref: 'headers.yaml#/components/headers/RateLimitLimit'
X-RateLimit-Remaining:
$ref: 'headers.yaml#/components/headers/RateLimitRemaining'
X-RateLimit-Reset:
$ref: 'headers.yaml#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: 'schemas.yaml#/components/schemas/CreateMeasurementResponse'
examples:
'0':
$ref: 'examples.yaml#/components/examples/createMeasurementResponse'
measurement200:
description: Success
content:
application/json:
schema:
allOf:
- $ref: 'schemas.yaml#/components/schemas/MeasurementOptionsConditions'
- $ref: 'schemas.yaml#/components/schemas/MeasurementResultsConditions'
- $ref: 'schemas.yaml#/components/schemas/MeasurementResponse'
examples:
pingMeasurement:
$ref: 'examples.yaml#/components/examples/getPingMeasurementResponse'
tracerouteMeasurement:
$ref: 'examples.yaml#/components/examples/getTracerouteMeasurementResponse'
simpleDnsMeasurement:
$ref: 'examples.yaml#/components/examples/getSimpleDnsMeasurementResponse'
traceDnsMeasurement:
$ref: 'examples.yaml#/components/examples/getTraceDnsMeasurementResponse'
mtrMeasurement:
$ref: 'examples.yaml#/components/examples/getMtrMeasurementResponse'
httpMeasurement:
$ref: 'examples.yaml#/components/examples/getHttpMeasurementResponse'
probes200:
description: Success
content:
application/json:
schema:
$ref: 'schemas.yaml#/components/schemas/Probes'
examples:
'0':
$ref: 'examples.yaml#/components/examples/probes'
Loading

0 comments on commit 03edd29

Please sign in to comment.