Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): Update oazapfts version to v4.3.3 (latest), enabling enum using a flag --useEnumType #4

Closed
wants to merge 112 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
a361005
fix: Encode query and path parameters
rtfpessoa Jul 12, 2021
0f62259
Add unionUndefined options for exactOptionalPropertyTypes (#234)
kahirokunn Jun 1, 2022
1bd7880
Downgrade open-api-mocker
jonkoops Jun 30, 2022
b5c3584
Allow application/problem+json response types (#197)
ehvattum Jun 30, 2022
cbd2c6c
chore(deps): bump minimist from 1.2.5 to 1.2.6
dependabot[bot] Jun 30, 2022
2d2e32e
chore(deps-dev): bump @jest/types from 27.5.1 to 28.1.1
dependabot[bot] Jun 30, 2022
99a1c42
chore(deps): bump validator from 13.6.0 to 13.7.0
dependabot[bot] Jun 30, 2022
c2674b9
Use Node.js 18 for CI (#241)
jonkoops Jun 30, 2022
243c957
Add support for uploading blobs (#55)
tmueller Jul 1, 2022
ccc89d3
chore(deps): bump typescript from 4.6.2 to 4.7.4
dependabot[bot] Jul 4, 2022
990650d
chore(deps-dev): bump @types/lodash from 4.14.177 to 4.14.182
dependabot[bot] Jul 4, 2022
60897c5
chore(deps-dev): bump husky from 7.0.4 to 8.0.1
dependabot[bot] Jul 4, 2022
6e36424
chore(deps-dev): bump prettier from 2.6.2 to 2.7.1
dependabot[bot] Jul 4, 2022
60ffdac
chore(deps-dev): bump openapi-types from 10.0.0 to 12.0.0
dependabot[bot] Jul 4, 2022
905b3a9
chore(deps): bump @apidevtools/swagger-parser from 10.0.3 to 10.1.0
dependabot[bot] Jul 4, 2022
dd29a84
chore(deps-dev): bump ts-node from 10.7.0 to 10.8.2
dependabot[bot] Jul 4, 2022
08f635f
chore(deps-dev): bump @types/node from 17.0.22 to 18.0.1
dependabot[bot] Jul 4, 2022
a14edf7
chore(deps-dev): bump lint-staged from 12.3.7 to 13.0.3
dependabot[bot] Jul 4, 2022
05906dd
chore(deps-dev): bump @types/node from 18.0.1 to 18.0.3
dependabot[bot] Jul 11, 2022
e16f614
Add support for properties outside allOf
kosky37 Aug 21, 2021
f27e96c
Add test for properties outside of allOf
kosky37 Jul 18, 2022
35967a9
Merge pull request #103 from rtfpessoa/encode-params
shocklateboy92 Jul 22, 2022
20f1e14
Merge pull request #120 from piotr121993/alternative-allof-schema
shocklateboy92 Jul 22, 2022
252b827
chore(deps-dev): bump @jest/types from 28.1.1 to 28.1.3
dependabot[bot] Jul 18, 2022
d9c6ce2
chore(deps-dev): bump ts-node from 10.8.2 to 10.9.1
dependabot[bot] Jul 18, 2022
f44f912
chore(deps-dev): bump @types/node from 18.0.3 to 18.0.6
dependabot[bot] Jul 23, 2022
49d648d
chore(deps-dev): bump @types/node from 18.0.6 to 18.6.1
dependabot[bot] Jul 25, 2022
05f9ffe
Merge pull request #261 from cellular/dependabot/npm_and_yarn/types/n…
shocklateboy92 Jul 25, 2022
2bbdee5
Allow application/geo+json response types (#258)
olof-nord Jul 26, 2022
6230d3f
chore(deps-dev): bump @types/node from 18.6.1 to 18.6.3
dependabot[bot] Aug 1, 2022
66f5c88
build: update dev dependencies (#267)
Xiphe Aug 5, 2022
ce300ba
chore(deps-dev): bump @types/node from 18.6.3 to 18.6.4
dependabot[bot] Aug 5, 2022
3e0d2fd
Add Dependabot config for Github Actions
jonkoops Aug 5, 2022
b7413a8
chore(deps): bump actions/checkout from 2 to 3
dependabot[bot] Aug 5, 2022
98895e0
chore(deps): bump actions/setup-node from 2 to 3
dependabot[bot] Aug 5, 2022
d05ce48
chore(deps-dev): bump @types/node from 18.6.4 to 18.7.3
dependabot[bot] Aug 15, 2022
0f8dbba
chore(deps-dev): bump @types/node from 18.7.3 to 18.7.9
dependabot[bot] Aug 22, 2022
48dcb48
chore(deps-dev): bump @types/jest from 28.1.6 to 28.1.7
dependabot[bot] Aug 22, 2022
2eca62a
chore(deps-dev): bump @types/lodash from 4.14.182 to 4.14.184
dependabot[bot] Aug 22, 2022
43cec51
chore(deps-dev): bump ts-jest from 28.0.7 to 28.0.8
dependabot[bot] Aug 22, 2022
5e840b5
refactor: apply prettier
Xiphe Aug 25, 2022
e3c8945
fix: filter empty query parameters before joining them
Xiphe Aug 25, 2022
7e7f48a
test(demo): add path to test query parameter serialization
Xiphe Aug 25, 2022
e2cc0d9
build(demo): update demo clients build from petstore.json
Xiphe Aug 25, 2022
76a6f48
fix(codegen): serialize object query parameters as exploded form by d…
Xiphe Aug 25, 2022
cce9c9c
chore(deps-dev): bump @types/node from 18.7.9 to 18.7.13
dependabot[bot] Aug 29, 2022
5630102
chore(deps): bump typescript from 4.7.4 to 4.8.2
dependabot[bot] Aug 29, 2022
1e068e1
Merge pull request #280 from cellular/standard-query-parameter-serial…
shocklateboy92 Sep 5, 2022
a2c97df
chore(deps-dev): bump @types/node from 18.7.13 to 18.7.15
dependabot[bot] Sep 5, 2022
3f2168c
chore(deps-dev): bump openapi-types from 12.0.0 to 12.0.2
dependabot[bot] Sep 5, 2022
914c17e
chore(deps): bump typescript from 4.8.2 to 4.8.3
dependabot[bot] Sep 12, 2022
7f5a5e7
chore(deps-dev): bump @types/lodash from 4.14.184 to 4.14.185
dependabot[bot] Sep 12, 2022
ca149bf
chore(deps-dev): bump @types/node from 18.7.15 to 18.7.16
dependabot[bot] Sep 12, 2022
054cb66
4.0.0
Xiphe Sep 12, 2022
d7be28b
feat: add support for 'const' keyword (#292)
smiley-uriux Sep 16, 2022
d965594
refactor: use unknown instead of any
Xiphe Sep 16, 2022
9b0bd4d
4.1.0
Xiphe Sep 16, 2022
a5bd72f
chore(deps-dev): bump @types/node from 18.7.16 to 18.7.18
dependabot[bot] Sep 19, 2022
d592815
chore(deps-dev): bump @types/node from 18.7.18 to 18.7.21 (#297)
dependabot[bot] Sep 26, 2022
8fac015
chore(deps): bump typescript from 4.8.3 to 4.8.4
dependabot[bot] Oct 3, 2022
a90ceca
chore(deps-dev): bump @types/lodash from 4.14.185 to 4.14.186
dependabot[bot] Oct 3, 2022
36a7aba
chore(deps-dev): bump @types/node from 18.7.21 to 18.8.0
dependabot[bot] Oct 3, 2022
eb189ea
chore(deps-dev): bump @types/node from 18.8.0 to 18.8.3 (#302)
dependabot[bot] Oct 10, 2022
2aa0748
chore(deps-dev): bump @types/node from 18.8.3 to 18.11.0
dependabot[bot] Oct 17, 2022
d73a087
chore(deps): bump minimist from 1.2.6 to 1.2.7
dependabot[bot] Oct 17, 2022
dc3f432
Upgrade Jest to version 29 (#306)
jonkoops Oct 17, 2022
e86c1a6
Upgrade `open-api-mocker` to latest version (#307)
jonkoops Oct 17, 2022
58beaec
Adding an option to generate typescript enum instead of union of strings
labmorales Oct 17, 2022
c751f42
Updating the readme to include the new enum option and the optimistic…
labmorales Oct 17, 2022
a84b6ec
Boolean enums are now represented by a union type
labmorales Oct 18, 2022
3f3b592
Removing sorting from imports
labmorales Oct 18, 2022
8c6ccda
chore(deps-dev): bump jest from 29.2.0 to 29.2.1
dependabot[bot] Oct 24, 2022
29a2c31
chore(deps-dev): bump @types/node from 18.11.0 to 18.11.4
dependabot[bot] Oct 24, 2022
94159f3
Use built-in Fetch API from Node.js (#242)
jonkoops Oct 24, 2022
f0d5905
fix pronunciation YouTube link
aSemy Oct 26, 2022
57b119a
Merge pull request #313 from aSemy/patch-1
Xiphe Oct 26, 2022
3697eeb
Merge pull request #308 from labmorales/add_typescript_enums
Xiphe Oct 28, 2022
d774571
4.2.0
Xiphe Oct 28, 2022
e2c1760
chore(deps-dev): bump @types/node from 18.11.4 to 18.11.8 (#315)
dependabot[bot] Oct 31, 2022
c9611b7
chore(deps-dev): bump jest from 29.2.1 to 29.2.2
dependabot[bot] Oct 31, 2022
7c518ae
chore(deps-dev): bump @types/jest from 29.2.0 to 29.2.2
dependabot[bot] Nov 7, 2022
41d8edc
chore(deps-dev): bump @types/node from 18.11.8 to 18.11.9
dependabot[bot] Nov 7, 2022
765112a
chore(deps-dev): bump @types/lodash from 4.14.186 to 4.14.188
dependabot[bot] Nov 7, 2022
87d155f
chore(deps-dev): bump jest from 29.2.2 to 29.3.0
dependabot[bot] Nov 8, 2022
53873d3
chore(deps-dev): bump husky from 8.0.1 to 8.0.2
dependabot[bot] Nov 8, 2022
7ba226e
build: rename master -> main
Xiphe Nov 9, 2022
d4e803f
chore(deps-dev): bump jest from 29.3.0 to 29.3.1
dependabot[bot] Nov 14, 2022
4e55656
feat: add support for RFC 7396
fgnass Nov 16, 2022
1510f4b
4.3.0
fgnass Nov 16, 2022
967e5f6
chore(deps): bump typescript from 4.8.4 to 4.9.3 (#334)
dependabot[bot] Nov 21, 2022
cb11fb1
chore(deps-dev): bump @types/jest from 29.2.2 to 29.2.3 (#333)
dependabot[bot] Nov 21, 2022
9d2f83c
chore(deps-dev): bump @types/lodash from 4.14.188 to 4.14.189 (#332)
dependabot[bot] Nov 21, 2022
d3b2c37
chore(deps-dev): bump lint-staged from 13.0.3 to 13.0.4
dependabot[bot] Nov 28, 2022
64c401d
chore(deps-dev): bump prettier from 2.7.1 to 2.8.0
dependabot[bot] Nov 28, 2022
54ff688
chore(deps-dev): bump @types/lodash from 4.14.189 to 4.14.190
dependabot[bot] Nov 28, 2022
2addf23
fix(generate): avoid name conflicts between types and enums
timmbuktu Nov 29, 2022
dfacdd6
fix(generate): add examples to demo directory
timmbuktu Nov 29, 2022
2a570df
chore(deps): updated all dependencies
swernerx Nov 18, 2022
052b309
fix(deps): fixed TS version to 4.7.x... breaking changes in later ver…
swernerx Nov 18, 2022
ea91d6d
fix: improved existance check for body parameter
swernerx Nov 18, 2022
c572dcc
fix: allow any body for JSON stringify as supported by the native met…
swernerx Nov 18, 2022
f733b6d
test: add test-case for JSON-string as request body
Xiphe Nov 30, 2022
b9178ff
fix: stop using deprecated ts-api
Xiphe Nov 30, 2022
5f5c06f
build: update dependencies
Xiphe Nov 30, 2022
f5a0180
4.3.1
Xiphe Nov 30, 2022
1a721e0
fix: do not allow string/boolean/number as form body
Xiphe Nov 30, 2022
8091117
4.3.2
Xiphe Nov 30, 2022
911c7e5
fix(generate): add testcase for name conflicts
timmbuktu Nov 30, 2022
5faa953
fix(generate): extend testcase
timmbuktu Nov 30, 2022
e1aa237
Merge pull request #340 from timmbuktu/fix/avoid-name-conflicts-betwe…
Xiphe Nov 30, 2022
b4c7ad7
4.3.3
Xiphe Nov 30, 2022
b72907e
chore(): Update oazapfts version to v4.3.3 (latest), enabling enum us…
Dec 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: npm
directory: /
open-pull-requests-limit: 999
rebase-strategy: disabled
schedule:
interval: "weekly"
interval: weekly
- package-ecosystem: github-actions
directory: /
open-pull-requests-limit: 999
rebase-strategy: disabled
schedule:
interval: weekly
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: CI
on:
push:
branches: [master]
branches: [main]
pull_request:
branches: [master]
branches: [main]
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18
check-latest: true
- run: npm ci
- run: npm test
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 🍻 oazapfts!

[![CI](https://github.com/cellular/oazapfts/actions/workflows/ci.yml/badge.svg)](https://github.com/cellular/oazapfts/actions/workflows/ci.yml)

Generate TypeScript clients to tap into OpenAPI servers.

## Features
Expand All @@ -26,22 +28,26 @@ oazapfts <spec> [filename]
Options:
--exclude, -e tag to exclude
--include, -i tag to include
--optimistic
--useEnumType
```

Where `<spec>` is the URL or local path of an OpenAPI or Swagger spec (in either json or yml) and `<filename>` is the location of the `.ts` file to be generated. If the filename is omitted, the code is written to stdout.

Use the `useEnumType` option to generate typescript enums instead of union of values.

## Overriding the defaults

The generated file exports a `defaults` constant that can be used to override the `basePath`, provide a custom `fetch` implementation or to send additional headers with each request:

```ts
import * as api from "./api.ts";
import nodeFetch from "node-fetch";
import * as api from './api.ts';
import nodeFetch from 'node-fetch';

api.default.basePath = "https://example.com/api";
api.default.basePath = 'https://example.com/api';

api.defaults.headers = {
access_token: "secret",
access_token: 'secret',
};

api.defaults.fetch = nodeFetch;
Expand Down Expand Up @@ -97,7 +103,7 @@ if (res.status === 404) {
The above code can be simplified by using the `handle` helper:

```ts
import { handle } from "oazapfts";
import { handle } from 'oazapfts';

await handle(api.getPetById(1), {
200(pet) {
Expand Down Expand Up @@ -127,7 +133,7 @@ await handle(api.getPetById(1), {
Instead of handling errors right in place we can also use the `ok` helper:

```ts
import { ok } from "oazapfts";
import { ok } from 'oazapfts';

const pet = await ok(api.getPetById(1));
```
Expand All @@ -137,8 +143,8 @@ With this pattern `pet` will be typed as `Pet` and a `HttpError` will be thrown
You can even turn your whole API into an optimistic one:

```ts
import { optimistic } from "oazapfts";
import * as rawApi from "./api.ts";
import { optimistic } from 'oazapfts';
import * as rawApi from './api.ts';

const api = optimistic(rawApi);
const pet = await api.getPetById(1);
Expand All @@ -150,7 +156,7 @@ Since version 3.1.0 you can also use the `--optimistic` flag on the command line

## About the name

The name comes from a combination of syllables **oa** (OpenAPI) and **ts** (TypeScript) and is [pronounced 🗣](https://youtu.be/chvb-K95rBE) like the Bavarian _O'zapt'is!_ (it's tapped), the famous words that mark the beginning of the Oktoberfest.
The name comes from a combination of syllables **oa** (OpenAPI) and **ts** (TypeScript) and is [pronounced 🗣](https://www.youtube.com/watch?v=chvb-K95rBE) like the Bavarian _O'zapt'is!_ (it's tapped), the famous words that mark the beginning of the Oktoberfest.

# License

Expand Down
80 changes: 80 additions & 0 deletions demo/allOf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"openapi": "3.0.1",
"info": {
"title": "Swagger allOf example",
"version": "1.0.0"
},
"servers": [
{
"url": "https://testUrl.test"
}
],
"paths": {
"/circle/{circle_id}": {
"get": {
"tags": ["circle"],
"summary": "Find circle by ID",
"description": "Returns a single circle",
"operationId": "getCircleById",
"parameters": [
{
"name": "circle_id",
"in": "path",
"description": "ID of circle to return",
"required": true,
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Circle"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Circle": {
"allOf": [
{
"$ref": "#/components/schemas/Shape"
},
{
"type": "object",
"properties": {
"radius": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
}
],
"properties": {
"circumference": {
"type": "integer",
"format": "int32"
}
}
},
"Shape": {
"type": "object",
"properties": {
"numberOfCorners": {
"type": "integer"
}
}
}
}
}
}
Loading