mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
docs: enhance and fix readme
This commit is contained in:
24
README.md
24
README.md
@@ -49,12 +49,12 @@ openstapps-core-tools src/core lib/schema
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import {Validator} from '@openstapps/core-tools';
|
import {Validator} from '@openstapps/core-tools';
|
||||||
import {SCDish} from '@openstapps/core';
|
import {SCDish, SCThingType} from '@openstapps/core';
|
||||||
import {ValidatorResult} from 'jsonschema';
|
import {ValidatorResult} from 'jsonschema';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
|
|
||||||
const objectToValidate: SCDish = {
|
const objectToValidate: SCDish = {
|
||||||
type: 'Dish',
|
type: SCThingType.Dish,
|
||||||
// more properties
|
// more properties
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,10 +62,10 @@ type: 'Dish',
|
|||||||
const validator = new Validator();
|
const validator = new Validator();
|
||||||
|
|
||||||
// make the validator read the schema files
|
// make the validator read the schema files
|
||||||
validator.addSchemas(join('node_modules', '@openstapps', 'core', 'lib', 'schema'));
|
validator.addSchemas(join('node_modules', '@openstapps', 'core', 'lib', 'schema')).then(() => {
|
||||||
|
// validate an object
|
||||||
// validate an object
|
const result: ValidatorResult = validator.validate(objectToValidate, 'SCDish');
|
||||||
const result: ValidatorResult = validator.validate(objectToValidate);
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using validateFiles function
|
#### Using validateFiles function
|
||||||
@@ -114,13 +114,13 @@ where:
|
|||||||
|
|
||||||
Command with the example arguments is then for example:
|
Command with the example arguments is then for example:
|
||||||
```shell
|
```shell
|
||||||
node_modules/.bin/openstapps-validate lib/schema src/test/resources
|
node_modules/.bin/openstapps-core-tools lib/schema src/test/resources
|
||||||
```
|
```
|
||||||
|
|
||||||
Inside of a script in `package.json` or if the npm package is installed globally, the tool `openstapps-validate` can be called without its local path (`node_modules/.bin`):
|
Inside of a script in `package.json` or if the npm package is installed globally, the tool `openstapps-validate` can be called without its local path (`node_modules/.bin`):
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
openstapps-validate lib/schema src/test/resources report.html
|
openstapps-core-tools lib/schema src/test/resources report.html
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generate documentation for routes
|
## Generate documentation for routes
|
||||||
@@ -132,3 +132,11 @@ The generator relies on dynamic imports and must therefore be run this way.
|
|||||||
```shell
|
```shell
|
||||||
node --require ts-node/register node_modules/@openstapps/core-tools/src/cli.ts routes PATH/TO/ROUTES.md
|
node --require ts-node/register node_modules/@openstapps/core-tools/src/cli.ts routes PATH/TO/ROUTES.md
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Pack definitions and implementations
|
||||||
|
|
||||||
|
To pack all the different files into two distribution files - one for definitions/one for implementations - use the following command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
openstapps-core-tools pack
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user