Skip to content

Commit

Permalink
Merge pull request #14 from nrccua/fix/missing_path_params
Browse files Browse the repository at this point in the history
[E4E-87]: Allow an empty input body to be passed to be passed in variables
  • Loading branch information
gsimionato-daitan authored Jan 7, 2022
2 parents 9b72b48 + b2d38d5 commit 08b7f9b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.3.2](https://github.com/nrccua/apollo-rest-utils/compare/1.3.1...1.3.2) (2022-01-07)


### Changes

* [E4E-87]: Allow some params to be optional, duh ([c507d2b](https://github.com/nrccua/apollo-rest-utils/commit/c507d2b2c81eda25cf4b7c75b5a77e0eba20309c))
* [E4E-87]: 1.3.1 ([494dae2](https://github.com/nrccua/apollo-rest-utils/commit/494dae20089d6bd9dff3d8942026dc1abfc059f0))

### [1.3.1](https://github.com/nrccua/apollo-rest-utils/compare/1.3.0...1.3.1) (2022-01-07)


### Changes

* [E4E-87]: Allow an empty input body to be passed to be passed in variables ([4b67e40](https://github.com/nrccua/apollo-rest-utils/commit/4b67e4033b6773a682b4363224076e9dcdf0f828))
* [E4E-87]: 1.3.0 ([cbda2b6](https://github.com/nrccua/apollo-rest-utils/commit/cbda2b6cef2483571b99b99943777aafb21c2449))

## [1.3.0](https://github.com/nrccua/apollo-rest-utils/compare/1.2.2...1.3.0) (2022-01-06)


Expand Down
4 changes: 3 additions & 1 deletion lib/generateRoutes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export function typeObjectFromParams(
params.forEach(p => {
const paramObject = p as ParameterObject;
if (paramObject.name) {
typeString += `${_.camelCase(paramObject.name)}: ${typeOfParam(paramObject)}; `;
typeString += `${_.camelCase(paramObject.name)}${
paramObject.required || paramObject.in === 'path' ? '' : '?'
}: ${typeOfParam(paramObject)}; `;
}
});

Expand Down
6 changes: 5 additions & 1 deletion lib/types/restSchema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export type RestResponse<T> = T extends IRestEndpoint<infer U, unknown> ? U : ne

export type RestRequest<T> = T extends IRestEndpoint<unknown, infer U> ? U : never;

export type Input<T> = T | { input: T };
// Allow for either:
// 1. All fields to put into an input object
// or
// 2. Allow an empty input object to overcome a bug in apollo-link-rest where PATCH/POST/PUT barfs with no body
export type Input<T> = (T & { input?: Record<string, never> }) | { input: T };

export interface IEndpointOptions<T, U> {
endpoint: IRestEndpoint<T, U>;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@
"update:version:major": "standard-version --release-as major",
"update:version:minor": "standard-version --release-as minor"
},
"version": "1.3.0"
"version": "1.3.2"
}

0 comments on commit 08b7f9b

Please sign in to comment.