Skip to content

move to openapi json definitions #933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: ta/enable-compression
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Compression is enabled by default, can be disabled by setting
`ENABLE_RESPONSE_COMPRESSION` to `false`. If using post-hooks, you must update
to hooks to handle compression or disable compression.
- OpenAPI definitions are now returned as JSON instead of YAML

## [4.2.0] - 2025-05-05

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,12 @@ Next, edit that file to make it specific to this server. For example:
- Fix each endpoint, especially the Landing Page defintion, which gets duplicated
- Add definitions for each tag

Then, convert the yaml to OpenAPI JSON document by running

```shell
yq -o=json src/lambdas/api/openapi.yaml > src/lambdas/api/openapi.json
```

To validate the resulting OpenAPI file, run

```shell
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"sls-remove": "sls remove",
"package": "sls package",
"serve": "REQUEST_LOGGING_FORMAT=dev LOG_LEVEL=debug STAC_API_URL=http://localhost:3000 ENABLE_TRANSACTIONS_EXTENSION=true nodemon --exec node --loader ts-node/esm ./src/lambdas/api/local.ts",
"build-api-docs": "npx @redocly/cli build-docs src/lambdas/api/openapi.yaml -o ./docs/index.html",
"build-api-docs": "npx @redocly/cli build-docs src/lambdas/api/openapi.json -o ./docs/index.html",
"prepare": "husky"
},
"ava": {
Expand Down
4 changes: 2 additions & 2 deletions src/lambdas/api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const pathName = process.env['LAMBDA_TASK_ROOT']

app.get('/api', async (_req, res, next) => {
try {
res.type('application/vnd.oai.openapi')
res.download(path.resolve(pathName, 'openapi.yaml'))
res.type('application/vnd.oai.openapi+json;version=3.0')
res.download(path.resolve(pathName, 'openapi.json'))
} catch (error) {
next(error)
}
Expand Down
Loading