Skip to content

Commit

Permalink
SCV-89: Updating the schema validator so that it will use the latest …
Browse files Browse the repository at this point in the history
…STAC version.
  • Loading branch information
jasongilman committed Jun 18, 2020
1 parent 87da23c commit c41f774
Show file tree
Hide file tree
Showing 25 changed files with 628 additions and 4,364 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@ $RECYCLE.BIN/

# IntelliJ
.idea/

stac-spec/
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ There is more detailed documentation in the [docs](docs/readme.md) folder of thi

### Setup

This application is a monorepo around a set of microservices that support the STAC proxy. It is organized as a NPM module and will install all dependencies if you run the following command:
This application is a service that support the STAC proxy. It is organized as a NPM module and will install all dependencies if you run the following command:

`npm install`
`bin/bootstrap.sh`

### Running locally

- cd `search`
- `npm start`
`npm start`

### Deploying

Expand Down
35 changes: 35 additions & 0 deletions bin/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

npm install
if [[ $? != 0 ]]; then
echo 'npm install failed'
exit 1
fi

if [[ ! -d stac-spec ]]; then
echo "Cloning stac-spec"
git clone "https://github.com/radiantearth/stac-spec.git"
if [[ $? != 0 ]]; then
echo 'git clone failed'
exit 1
fi
fi
cd stac-spec
git checkout 37ff5fe75f3639e25d452f483a2c84a7c34374bf
if [[ $? != 0 ]]; then
echo 'git checkout failed'
exit 1
fi
cd ..

compile_schema() {
node bin/compile_schema.js $1 $2
if [[ $? != 0 ]]; then
echo 'Compilation failed'
exit 1
fi
}

compile_schema stac-spec/item-spec/json-schema/item.json search/docs/item.json
compile_schema stac-spec/catalog-spec/json-schema/catalog.json search/docs/catalog.json
compile_schema stac-spec/collection-spec/json-schema/collection.json search/docs/collection.json
28 changes: 28 additions & 0 deletions bin/compile_schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const $RefParser = require('@apidevtools/json-schema-ref-parser');
const fs = require('fs');
const { promisify } = require('util');
const writeFile = promisify(fs.writeFile);

const args = process.argv.slice(2);

if (args.length !== 2) {
console.error('Expects two arguments: source schema file and output file');
process.exit(1);
}

const [sourceSchemaFile, outputFile] = args;

(async () => {
const derefed = await $RefParser.dereference(sourceSchemaFile, {
dereference: {
circular: 'ignore'
}
});
await writeFile(outputFile, JSON.stringify(derefed, null, 2));
})()
.then(() => {
console.log(`Output ${outputFile}`);
}).catch((error) => {
console.log(error);
process.exit(1);
});
Loading

0 comments on commit c41f774

Please sign in to comment.