Skip to content

Commit

Permalink
Remove JSON schema validation pathway entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
eddie-atkinson committed Jul 26, 2024
1 parent 873a0a5 commit e26d266
Show file tree
Hide file tree
Showing 42 changed files with 276 additions and 12,063 deletions.
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ jobs:
# Check for TypeScript errors
- run: yarn test:ts

# Check that schema is up-to-date
- run: scripts/schema-check.sh

- run: yarn prettier --check src tests tests-modules

# run tests!
Expand Down
16 changes: 5 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ work and submitting your PR.

All PRs should be submitted against the `devel` branch (github default).

**Changing TypeScript Interfaces**

Run `yarn generateSchema` after changing any interfaces, this will regenerate
the `schema.json` file which is used for run-time tests.

**Commit Messages**

Commit messages should follow the
Expand Down Expand Up @@ -134,12 +129,11 @@ TODO
Checklist:

1. Create it in `src/modules/myAmazingModule.ts`
1. Run `yarn generateSchema` (and on any future interface changes)
1. Test it in `src/modules/myAmazingModule.spec.ts`
1. Add it to `src/index-common.ts`
1. Docs in `docs/modules/myAmazingModule.md`
1. Link these docs in `README.md` and `docs/README.md`.
1. Commit all the above and any `tests/http/*` created in your tests.
2. Test it in `src/modules/myAmazingModule.spec.ts`
3. Add it to `src/index-common.ts`
4. Docs in `docs/modules/myAmazingModule.md`
5. Link these docs in `README.md` and `docs/README.md`.
6. Commit all the above and any `tests/http/*` created in your tests.

For a model example, see the
[recommendationsBySymbol PR](https://github.com/gadicc/node-yahoo-finance2/pull/28)
Expand Down
23 changes: 0 additions & 23 deletions docs/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,6 @@ simply set:
yahooFinance.setGlobalConfig({ validation: { logErrors: false} });
```

<a name="note-additional-props"></a>
## A Note on "Additional Properties"

*Since v2.2 (March 2022)*

We now allow "additional properties" on results received from Yahoo.

This means that while we can still guarantee the type of all known fields we
receive back, we'll no longer throw a new error on new unknown keys.

This is important because Yahoo constantly add new fields, and this would
break all existing deployments.

You can revert to the old behaviour with:

```js
yahooFinance._disallowAdditionalProps();
```

which is the default when `NODE_ENV==="test"`. This means that during our
development of the library itself, we make sure that we're testing against
all types.

<a name="help-fix"></a>
## Help Fix Validation Errors

Expand Down
14 changes: 2 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@
"scripts": {
"coverage": "yarn test --coverage",
"lint": "eslint . --ext .js,.ts",
"//schema": "ts-json-schema-generator -f tsconfig.json -p 'src/{modules/**/*.ts,lib/options.ts}' -t '*' | node bin/schema-tweak.js > schema.json",
"schema": "node --loader ts-node/esm scripts/schema.js > schema.json",
"timeseries": "node --loader ts-node/esm scripts/timeseries.js",
"build": "yarn run build:esm && yarn run build:cjs && yarn run build:post",
"build": "yarn run build:esm && yarn run build:cjs",
"build:esm": "tsc --module es2020 --target es2019 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es2015 --outDir dist/cjs && sed 's/\"type\": \"module\",/\"type:\": \"commonjs\",/' dist/cjs/package.json > dist/cjs/package-changed.json && mv dist/cjs/package-changed.json dist/cjs/package.json",
"build:post": "scripts/json-transform.sh",
"generateSchema": "yarn schema",
"prepublishOnly": "yarn build && yarn generateSchema && yarn build:post",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
"test:ts": "tsc --noEmit",
"test:esm": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js -c tests-modules/esm/jest.config.js tests-modules/esm/tests/*",
Expand All @@ -54,14 +49,11 @@
"test:build": "yarn test:modules"
},
"files": [
"dist",
"schema.json"
"dist"
],
"dependencies": {
"@sinclair/typebox": "^0.32.27",
"@types/tough-cookie": "^4.0.2",
"ajv": "8.10.0",
"ajv-formats": "2.1.1",
"node-fetch": "^2.6.1",
"tough-cookie": "^4.1.2",
"tough-cookie-file-store": "^2.0.3"
Expand All @@ -84,11 +76,9 @@
"globby": "13.2.2",
"jest": "29.7.0",
"jest-tobetype": "1.2.3",
"oas-schema-walker": "1.1.5",
"prettier": "2.8.8",
"semantic-release": "19.0.5",
"ts-jest": "29.1.2",
"ts-json-schema-generator": "1.5.0",
"ts-node": "10.9.2",
"typescript": "5.4.3"
}
Expand Down
Loading

0 comments on commit e26d266

Please sign in to comment.