Skip to content

Commit 32465ab

Browse files
authored
Commit source schemas to Git (openapi-ts#978)
1 parent 585e294 commit 32465ab

File tree

1,337 files changed

+634712
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,337 files changed

+634712
-40
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ bin
22
coverage
33
dist
44
examples
5-
test/fixtures

.github/workflows/ci.yml

-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
with:
3333
node-version: 18
3434
- run: pnpm i
35-
- run: npm run download:schemas
3635
- run: npm run test:coverage
3736
test-node-versions:
3837
runs-on: ubuntu-22.04
@@ -48,7 +47,6 @@ jobs:
4847
with:
4948
node-version: ${{ matrix.node-version }}
5049
- run: pnpm i
51-
- run: npm run download:schemas
5250
- run: npm test
5351
test-macos:
5452
runs-on: macos-12
@@ -61,5 +59,4 @@ jobs:
6159
with:
6260
version: 18
6361
- run: pnpm i
64-
- run: npm run download:schemas
6562
- run: npm test

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
coverage/
33
dist
44
node_modules
5-
test/fixtures/**/*

.prettierignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
examples/**/*.ts
2-
test/fixtures/**/*
3-
*.md
1+
examples
42
*.yaml
53
*.yml

CONTRIBUTING.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ This library has both unit tests (tests that test a tiny part of a schema) and s
5555

5656
For most PRs, **snapshot tests can be avoided.** But for scenarios similar to the ones mentioned, they can ensure everything is working as expected.
5757

58+
#### Updating snapshot tests
59+
60+
To add a schema as a snapshot test, modify the [/scripts/download-schemas.ts](/scripts/download-schemas.ts) script with a path to download. There are both single-file schemas as well as multi-file schemas.
61+
5862
### Generating types
5963

6064
It may be surprising to hear, but _generating TypeScript types from OpenAPI is opinionated!_ Even though TypeScript and OpenAPI are very close relatives, both being JavaScript/JSON-based, they are nonetheless 2 different languages and thus there is always some room for interpretation. Likewise, some parts of the OpenAPI specification can be ambiguous on how they’re used, and what the expected type outcomes may be (though this is generally for more advanced usecasees, such as specific implementations of `anyOf` as well as [discriminator](https://spec.openapis.org/oas/latest.html#discriminatorObject) and complex polymorphism).
@@ -82,7 +86,6 @@ This library uses [Vitest](https://vitest.dev/) for testing. There’s a great [
8286

8387
To run the entire test suite once, run:
8488

85-
8689
```bash
8790
npm test
8891
```
@@ -106,3 +109,11 @@ To run ESLint on the project:
106109
```bash
107110
npm run lint
108111
```
112+
113+
### Updating snapshot examples
114+
115+
⚠️ This may break tests if schemas have been updated
116+
117+
```bash
118+
npm run update:examples
119+
```

examples/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# openapi-typescript examples
2+
3+
These examples show the generation from an OpenAPI schema to its associated types. None of the example schemas here are associated with this project, and all code are © their respective owners.
4+
5+
| Generated Types | Source | License |
6+
| :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------- |
7+
| `digital-ocean-api.ts` | [GitHub](https://github.com/digitalocean/openapi) | [Apache 2.0](https://github.com/digitalocean/openapi/blob/main/LICENSE) |
8+
| `github-api.ts` | [GitHub](https://github.com/github/rest-api-description/tree/main/descriptions/api.github.com) | [MIT](https://github.com/github/rest-api-description/blob/main/LICENSE.md) |
9+
| `github-api-next.ts` | [GitHub](https://github.com/github/rest-api-description/tree/main/descriptions-next/api.github.com) | [MIT](https://github.com/github/rest-api-description/blob/main/LICENSE.md) |
10+
| `octokit-ghes-3.6-diff-to-api.ts` | [GitHub](https://github.com/octokit/octokit-next.js/tree/main/packages/types-openapi-ghes-3.6-diff-to-api.github.com) | [MIT](https://github.com/octokit/octokit-next.js/blob/main/LICENSE) |
11+
| `stripe-api.ts` | [GitHub](https://github.com/stripe/openapi) | [MIT](https://github.com/stripe/openapi/blob/master/LICENSE) |

examples/digital-ocean-api/DigitalOcean-public.v2.yaml

+1,544
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)