Skip to content

Commit 568bb2c

Browse files
CMR-10210: Fix 502 gateway error on cmr-stac index.html/documentation & CMR-10208: Add content type in stac response to match service-desc (#384)
* CMR-10210: Try regenerating documentation with redocly * CMR-10210: Clean up more markdown linter warnings; add documentation on using the stac validator * CMR-10210: Add note about using the stac-validator * CMR-10210: Update the type field for the rootcatalog service-desc response * CMR-10208: Update mimetype for documentation endpoint with the correct Iana spec * EDSC-10210: Update media type for `service-desc` to `application/yaml`
1 parent de46a4c commit 568bb2c

8 files changed

Lines changed: 774 additions & 679 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# NASA CMR STAC
2+
23
NASA's [Common Metadata Repository (CMR)](https://cmr.earthdata.nasa.gov/search) is a metadata
34
catalog of NASA Earth Science data. [STAC, or SpatioTemporal Asset Catalog](https://stacspec.org/), is a
45
[Specification](https://github.com/radiantearth/stac-spec) for describing geospatial data with
@@ -7,6 +8,7 @@ catalog of NASA Earth Science data. [STAC, or SpatioTemporal Asset Catalog](http
78
for searching and browsing STAC catalogs.
89

910
## CMR-STAC
11+
1012
CMR-STAC acts as a proxy between the CMR repository and STAC API queries.
1113
The goal is to expose CMR's vast collections of geospatial data as a STAC-compliant API.
1214
Even though the core metadata remains the same, a benefit of the CMR-STAC proxy is the ability
@@ -20,11 +22,15 @@ CMR-STAC follows the STAC API 1.0.0-beta.1 specification, see the
2022
[OpenAPI Documentation](https://api.stacspec.org/v1.0.0-beta.1/index.html).
2123

2224
## Usage
25+
2326
### Endpoints
27+
2428
- [CMR-STAC](https://cmr.earthdata.nasa.gov/stac): The entire catalog of NASA CMR data, organized by provider.
29+
2530
- [CMR-CLOUDSTAC](https://cmr.earthdata.nasa.gov/cloudstac): Also organized by provider, this API only contains STAC Collections where the Item Assets are available "in the cloud" (i.e., on S3).
2631

2732
### Navigating
33+
2834
CMR-STAC can be navigated manually using the endpoints provided above, or you can utilize available STAC software to browse and use the API.
2935

3036
A common STAC utility is Radiant Earth's `stac-browser` to use this tool against your development server navigate to
@@ -33,13 +39,17 @@ A common STAC utility is Radiant Earth's `stac-browser` to use this tool against
3339
See the [Usage Documentation](docs/usage/usage.md) for examples of how to interact with the API and search for data.
3440

3541
### Limitations
42+
3643
While CMR-STAC provides some advantages over the CMR, there are some limitations that you should be aware of:
44+
3745
- Limited search functionality: CMR-STAC does not support all of the search capabilities that CMR provides. For example, with CMR, you can search for data based on temporal and spatial criteria, as well as specific parameters such as platform, instrument, and granule size. However, with CMR-STAC, you can only search based on the STAC standard.
3846
- Limited metadata availability: CMR-STAC only provides metadata that follows the STAC specification. While this metadata is very rich and comprehensive, it may not provide all of the information that you need for your specific use case.
3947

4048
## For Developers
49+
4150
[Developer README](docs/README.md)
4251

4352
## License
53+
4454
NASA Open Source Agreement v1.3 (NASA-1.3)
4555
See [LICENSE.txt](./LICENSE.txt)

docs/README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
## CMR-STAC Development
1+
# CMR-STAC Development
22

33
CMR-STAC is a Node.js application built on the [Express.js framework](https://expressjs.com/) and deployed as an AWS serverless application using API Gateway + Lambda. This README is intended for developers who want to contribute to CMR-STAC, or set up a development environment for it.
44

55
The remainder of this README is documentation for developing, testing, and deploying CMR-STAC. See the [Usage documentation](../docs/usage/usage.md) if you are interested in using the CMR-STAC API.
66

7-
### Repository Structure
7+
## Repository Structure
88

99
| Directory | Description |
1010
| -------------------- | ------------ |
@@ -14,6 +14,7 @@ The remainder of this README is documentation for developing, testing, and deplo
1414
| [usage](../docs/usage/usage.md) | Documentation on usage of the CMR-STAC endpoint(s) |
1515

1616
## Getting Started
17+
1718
### Setup
1819

1920
Set the correct NodeJS version (specified in [.nvmrc](../.nvmrc) required
@@ -49,11 +50,38 @@ npm run dev
4950

5051
This will run the process in the current terminal session, the local server will be available at:
5152

52-
```
53+
```bash
5354
http://localhost:3000/stac
5455
http://localhost:3000/cloudstac
5556
```
5657

58+
### Creating index.html from Swagger.json
59+
60+
To Create the index.html located in docs/index we can use the `redocly` service
61+
the most straightforward way to do this is to use the cli tool against our `swagger.json` file
62+
63+
```bash
64+
npx @redocly/cli build-docs swagger.json
65+
```
66+
67+
### Testing STAC validation
68+
69+
We can test our API both locally and on deployed instance against the on a stac-validation service using the <https://github.com/stac-utils/stac-api-validator> tool
70+
71+
The tool can be installed using pip and requires a Python runtime
72+
73+
```bash
74+
pip install stac-api-validator
75+
```
76+
77+
```bash
78+
stac-api-validator\
79+
--root-url http://localhost:3000/stac/CMR_ONLY \
80+
--conformance core
81+
```
82+
83+
this can be extended to validate against additional conformance APIs
84+
5785
### Deploying
5886

5987
The deployment is handled via the [Serverless Framework](https://serverless.com). Each service has a
@@ -85,4 +113,4 @@ npm run deploy:docs -- --stage <sit|uat|prod>
85113
## License
86114

87115
NASA Open Source Agreement v1.3 (NASA-1.3)
88-
See [LICENSE.txt](../LICENSE.txt)
116+
See [LICENSE.txt](../LICENSE.txt)

docs/index/index.html

Lines changed: 716 additions & 660 deletions
Large diffs are not rendered by default.

docs/usage/usage.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ deployed to production. UAT CMR-STAC uses the UAT CMR environment which has a mu
1616

1717
Due to the vast number of collections contained within CMR, a user cannot query across all granules at once.
1818
[Attempting to do so returns an error message](https://cmr.earthdata.nasa.gov/search/granules.json)
19-
indicating that at least one of a set of fields must be provided.
20-
Because a STAC API allows for searching across all Items (i.e., granules), instead of a single API,
19+
indicating that at least one of a set of fields must be provided.
20+
Because a STAC API allows for searching across all Items (i.e., granules), instead of a single API,
2121
CMR-STAC provides multiple APIs, one for each provider. Upon hitting the root endpoint (https://cmr.earthdata.nasa.gov/stac)
2222
the response will include a list of CMR providers as a series of links
2323
with a "rel" field equal to "child".
@@ -34,7 +34,7 @@ with a "rel" field equal to "child".
3434
Navigating to a provider yields a STAC Catalog, but one that has some additional links and a
3535
`conformsTo` field, indicating that it is a STAC API. These links include:
3636

37-
| rel | path | Decription |
37+
| rel | path | Description |
3838
| --- | ---- | ---------- |
3939
| self | /{providerId} | this provider catalog |
4040
| root | / | the root CMR-STAC catalog |
@@ -55,10 +55,10 @@ is given here. The table shows the different endpoints available from the root c
5555
| ---- | ----------- |
5656
| / | Root endpoint. Returns a list of provider Catalogs |
5757
| /{provider-id} | Returns singular provider Catalog |
58-
| /{provider-id}/collections | Returns a Catalog of all Collections that belong to the indicated provider |
59-
| /{provider-id}/collections/{collection-id} | Returns the individual Collection indicated in the path |
60-
| /{provider-id}/collections/{collection-id}/items | Returns an ItemCollection of all Items contained in the indicated Collection |
61-
| /{provider-id}/collections/{collection-id}/items/{item-id} | Returns the individual Item indicated in the path |
58+
| /{provider-id}/collections | Returns a Catalog of all Collections that belong to the indicated provider |
59+
| /{provider-id}/collections/{collection-id} | Returns the individual Collection indicated in the path |
60+
| /{provider-id}/collections/{collection-id}/items | Returns an ItemCollection of all Items contained in the indicated Collection |
61+
| /{provider-id}/collections/{collection-id}/items/{item-id} | Returns the individual Item indicated in the path |
6262

6363
For example, if a user wanted to get all the collections under the ASF provider, the user would hit:
6464

@@ -88,7 +88,8 @@ Each Item returned from CMR-STAC includes a series of links as well:
8888
| via | The original CMR metadata used to generate the STAC metadata returned |
8989

9090
## Browsing
91-
The first thing to do when getting familiar with CMR-STAC is to browse through the catalog and get a sense for its structure, and what types of data (Collections and Items) are available.
91+
92+
The first thing to do when getting familiar with CMR-STAC is to browse through the catalog and get a sense for its structure, and what types of data (Collections and Items) are available.
9293
The easiest way to browse is to install a JSON extension for your browser of choice (e.g., [JSON Formatter](https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa/related) for Chrome).
9394

9495
![](https://s3.gifyu.com/images/cmr-stac-browse-opt.gif)
@@ -139,6 +140,7 @@ JSON Body:
139140
```
140141

141142
## Searching Collections
143+
142144
Similar to searching for Items, CMR-STAC provides endpoints to search for Collections. Both GET and POST requests are supported for collection searches.
143145

144146
| Parameter | Type | Description |
@@ -152,7 +154,6 @@ Similar to searching for Items, CMR-STAC provides endpoints to search for Collec
152154

153155
GET:
154156

155-
156157
https://localhost:3000/stac/LARC_ASDC/collections?bbox=-180,-90,180,90&datetime=2000-01-01T00:00:00Z/2022-01-01T00:00:00Z&keyword=atmosphere
157158

158159
**To sort the results:**

src/__tests__/providerCatalog.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe("GET /:provider", () => {
109109

110110
const link: Link = catalog.links.find((l: Link) => l.rel === "service-desc");
111111
expect(link).to.have.property("rel", "service-desc");
112-
expect(link).to.have.property("type", "application/vnd.oai.openapi;version=3.0");
112+
expect(link).to.have.property("type", "application/yaml");
113113
expect(link).to.have.property("href", "https://api.stacspec.org/v1.0.0-beta.1/openapi.yaml");
114114
expect(link).to.have.property("title", "OpenAPI Doc");
115115
});

src/domains/collections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const extractLicense = (_collection: Collection) => {
9797
};
9898

9999
/**
100-
* Examing a collections related URLs to see if it contains a reference to a STAC catalog.
100+
* Examining a collections related URLs to see if it contains a reference to a STAC catalog.
101101
* If the collection has a RelatedURL of type: "GET CAPABILITIES",
102102
* and subtype: "STAC" then that URL should be placed in the href for the items link.
103103
*

src/routes/catalog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const generateSelfLinks = (req: Request, nextCursor?: string | null, count?: num
5151
{
5252
rel: "service-desc",
5353
href: "https://api.stacspec.org/v1.0.0-beta.1/openapi.yaml",
54-
type: "application/vnd.oai.openapi;version=3.0",
54+
type: "application/yaml",
5555
title: "OpenAPI Doc",
5656
},
5757
{

src/routes/rootCatalog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const selfLinks = (req: Request): Link[] => {
2525
},
2626
{
2727
rel: "service-desc",
28-
href: `${stacRoot}/resources/swagger.json`,
29-
title: "OpenAI Documentation",
30-
type: "application/vnd.oai.openapi+json;version=3.0",
28+
href: `https://api.stacspec.org/v1.0.0-beta.1/openapi.yaml`,
29+
title: "OpenAPI Documentation",
30+
type: "application/yaml",
3131
},
3232
{
3333
rel: "service-doc",

0 commit comments

Comments
 (0)