Skip to content

Commit baf3814

Browse files
authored
Release 5.0.0 (#149)
* BREAKING_CHANGE: fully refactored http-client.eta template; feat: image content kind; feat: request content type auto substitution * chore: update funding * feat: RequestHeaders, RequestParams types (issue #150, thanks @Fabiencdp); chore: removed apiConfig.generic usage in templates * internal: rename test scripts; docs: update CHANGELOG * fix: try to fix pseudo duplicated operationIds (issue #152, thanks @RoXuS for report) * feat: --default-response option; BREAKING_CHANGE: changed the default response body type ('any' -> 'void') * fix: remove hard coded request content type (issue #153, thanks @po5i); BREAKING_CHANGE: changed request body transformation * feat: request cancellation support (issue #96, thanks @ApacheEx) * bump: up project version to 5.0.0 * fix: critical bug with `:paramName` path params (issue #149)
1 parent 0f6a69c commit baf3814

Some content is hidden

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

82 files changed

+17479
-11132
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
# These are supported funding model platforms
2-
3-
github: [js2me]
4-
patreon: js2me
5-
open_collective: # Replace with a single Open Collective username
61
ko_fi: js2me
7-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9-
liberapay: # Replace with a single Liberapay username
10-
issuehunt: # Replace with a single IssueHunt username
11-
otechie: # Replace with a single Otechie username
12-
custom: ['https://paypal.me/acacode'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
2+
custom: ["https://paypal.me/acacode"]

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# next release
22

3+
# 5.0.0
4+
5+
Fixes:
6+
- Request content types auto substitution
7+
i.e. if request body is form data, then request body content type will be `multipart/form-data`
8+
- Strange method name (issue #152, thanks @RoXuS)
9+
- Hardcoded Content-Type causes issues with some endpoints (issue #153, thanks @po5i)
10+
- Critical bug with `:paramName` path params (issue #154)
11+
12+
Features:
13+
- Ability to provide custom formatting `fetch` response
14+
- `"IMAGE"` content kind for response\request data objects
15+
- `RequestParams` `RequestHeaders` types for `--route-types` (`routeTypes: true`) option (issue #150, thanks @Fabiencdp )
16+
- `--default-response` option. Allows to set default type for empty response schema (default: `void`) (based on issue #14)
17+
- Request cancellation support (issue #96, thanks @ApacheEx)
18+
`RequestParams` type now have the `cancelToken` field
19+
`HttpClient` instance now have the `abortRequest(cancelToken)` method
20+
21+
BREAKING_CHANGES:
22+
- Fully refactored `http-client.eta` template, make it more flexible and simpler.
23+
`HttpClient["request"]` takes one argument with type `FullRequestParams`
24+
(previously it takes many count of arguments which was not flexible)
25+
- Changed the default response body type from `any` to `void` (issue #14)
26+
27+
Internal:
28+
- Changed templates:
29+
- `http-client.eta`
30+
- `procedure-call.eta`
31+
- `api.eta`
32+
33+
This version works with previous templates.
34+
335
# 4.4.0
436

537
Fixes:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Options:
5858
--modular generate separated files for http client, data contracts, and routes (default: false)
5959
--disableStrictSSL disabled strict SSL (default: false)
6060
--clean-output clean output folder before generate api. WARNING: May cause data loss (default: false)
61+
--default-response <type> default type for empty response schema (default: "void")
6162
-h, --help display help for command
6263
```
6364

index.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ interface GenerateApiParams {
7777
* prettier configuration
7878
*/
7979
prettier?: object;
80+
/**
81+
* default type for empty response schema (default: "void")
82+
*/
83+
defaultResponseType?: boolean;
8084
cleanOutput?: boolean;
8185
enumNamesAsValues?: boolean;
8286

@@ -215,7 +219,7 @@ export interface GenerateApiConfiguration {
215219
componentsMap: Record<string, SchemaComponent>;
216220
convertedFromSwagger2: boolean;
217221
moduleNameIndex: number;
218-
disableStrictSSSL: boolean;
222+
disableStrictSSL: boolean;
219223
extractRequestParams: boolean;
220224
fileNames: {
221225
dataContracts: string;

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const { Command } = require("commander");
1010
const { resolve } = require("path");
1111
const { generateApi } = require("./src");
1212
const { version, name: packageName } = require("./package.json");
13+
const { TS_KEYWORDS } = require("./src/constants");
1314

1415
const program = new Command(packageName);
1516

@@ -61,6 +62,7 @@ program
6162
0,
6263
)
6364
.option("--disableStrictSSL", "disabled strict SSL", false)
65+
.option("--default-response <type>", "default type for empty response schema", TS_KEYWORDS.VOID)
6466
.option(
6567
"--clean-output",
6668
"clean output folder before generate api. WARNING: May cause data loss",
@@ -86,6 +88,7 @@ const {
8688
enumNamesAsValues,
8789
disableStrictSSL,
8890
cleanOutput,
91+
defaultResponse,
8992
} = program;
9093

9194
generateApi({
@@ -94,6 +97,7 @@ generateApi({
9497
generateRouteTypes: routeTypes,
9598
generateClient: client,
9699
defaultResponseAsSuccess: defaultAsSuccess,
100+
defaultResponseType: defaultResponse,
97101
generateUnionEnums: unionEnums,
98102
generateResponses: responses,
99103
extractRequestParams: extractRequestParams,

0 commit comments

Comments
 (0)