Skip to content

Commit e95e4d3

Browse files
authored
Fix: Pass down parameters (#13) (#14)
* fix: request parameter schemas not passed down - Fixes the bug that `requestParameterSchemas` of a parent resource were not passed down to child resources if they have non-null `defaultMethodOptions`. Merges `requestParameterSchemas` in `defaultMethodOptions` before passing `ResourceOptions` to the underlying `aws-apigateway.Resource.addResource` method so that the merge of `defaultMethodOptions` by `aws-apigateway.Resource` does not replace `requestParameterSchemas` of the parent resource. issue #13 * chore: bump version to 0.2.3 - Bumps version to 0.2.3. - Bumps `aws-cdk-lib` and `constructs` to the latest versions as of this commit. The installed versions in `pnpm-lock.yaml` were already the latest. * feat(example): add nested path parameter - Adds a nested path parameter `{photoId}` under `/pet/{petId}/photo` to test if parameters are passed down. The GET endpoint returns a PNG image of a single transparent dot, which is implemented in a new file `lib/example-stack.getimage.ts`. * chore(example): update example output * docs: update README - Bumps version to 0.2.3 in the installation command. - Bumps Node.js to 18.x in the authorizer example. * docs: update API documentation
1 parent 9eeed44 commit e95e4d3

File tree

63 files changed

+380
-192
lines changed

Some content is hidden

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

63 files changed

+380
-192
lines changed

README.ja.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
このレポジトリを依存関係(`dependencies`)に追加してください。
2222

2323
```sh
24-
npm install https://github.com/codemonger-io/cdk-rest-api-with-spec.git#v0.2.2
24+
npm install https://github.com/codemonger-io/cdk-rest-api-with-spec.git#v0.2.3
2525
```
2626

2727
このライブラリはCDK v2プロジェクトで使用することを想定しており、以下のモジュールは`dependencies`ではなく`peerDependencies`に含んでいます。
@@ -297,7 +297,7 @@ const authorizer = augmentAuthorizer(
297297
{
298298
handler: new nodejs.NodejsFunction(this, 'authorizer', {
299299
description: 'Example authorizer',
300-
runtime: lambda.Runtime.NODEJS_16_X,
300+
runtime: lambda.Runtime.NODEJS_18_X,
301301
}),
302302
},
303303
),

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This library is implemented for the CDK **version 2** (CDK v2) and does not work
2121
Please add this repository to your dependencies.
2222

2323
```sh
24-
npm install https://github.com/codemonger-io/cdk-rest-api-with-spec.git#v0.2.2
24+
npm install https://github.com/codemonger-io/cdk-rest-api-with-spec.git#v0.2.3
2525
```
2626

2727
This library is supposed to be used in a CDK v2 project, so it does not include the following modules in the `dependencies` but does in the `peerDependencies`.
@@ -297,7 +297,7 @@ const authorizer = augmentAuthorizer(
297297
{
298298
handler: new nodejs.NodejsFunction(this, 'authorizer', {
299299
description: 'Example authorizer',
300-
runtime: lambda.Runtime.NODEJS_16_X,
300+
runtime: lambda.Runtime.NODEJS_18_X,
301301
}),
302302
},
303303
),

api-docs/markdown/cdk-rest-api-with-spec.augmentauthorizer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## augmentAuthorizer() function
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Makes a given [aws\_apigateway.IAuthorizer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IAuthorizer.html) an [IAuthorizerWithSpec](./cdk-rest-api-with-spec.iauthorizerwithspec.md) by augmenting it with a specified security scheme object.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
export declare function augmentAuthorizer(authorizer: apigateway.IAuthorizer, securitySchemeObject: SecuritySchemeObject): IAuthorizerWithSpec;
@@ -22,7 +22,7 @@ export declare function augmentAuthorizer(authorizer: apigateway.IAuthorizer, se
2222
| authorizer | apigateway.IAuthorizer | Authorizer to be augmented. |
2323
| securitySchemeObject | SecuritySchemeObject | Security scheme object to add to <code>authorizer</code>. |
2424

25-
<b>Returns:</b>
25+
**Returns:**
2626

2727
[IAuthorizerWithSpec](./cdk-rest-api-with-spec.iauthorizerwithspec.md)
2828

api-docs/markdown/cdk-rest-api-with-spec.iauthorizerwithspec.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
## IAuthorizerWithSpec interface
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Authorizer augmented with the features to describe the OpenAPI definition.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
export interface IAuthorizerWithSpec extends apigateway.IAuthorizer
1616
```
17-
<b>Extends:</b> apigateway.IAuthorizer
17+
**Extends:** apigateway.IAuthorizer
1818
1919
## Properties
2020
2121
| Property | Modifiers | Type | Description |
2222
| --- | --- | --- | --- |
23-
| [securitySchemeObject?](./cdk-rest-api-with-spec.iauthorizerwithspec.securityschemeobject.md) | | SecuritySchemeObject | <b><i>(BETA)</i></b> <i>(Optional)</i> Security scheme object representing this authorizer. |
23+
| [securitySchemeObject?](./cdk-rest-api-with-spec.iauthorizerwithspec.securityschemeobject.md) | | SecuritySchemeObject | **_(BETA)_** _(Optional)_ Security scheme object representing this authorizer. |
2424

api-docs/markdown/cdk-rest-api-with-spec.iauthorizerwithspec.securityschemeobject.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## IAuthorizerWithSpec.securitySchemeObject property
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Security scheme object representing this authorizer.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
securitySchemeObject?: SecuritySchemeObject;

api-docs/markdown/cdk-rest-api-with-spec.iresourcewithspec.addmethod.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## IResourceWithSpec.addMethod() method
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Adds a method with the OpenAPI definition.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
addMethod(httpMethod: string, target?: apigateway.Integration, options?: MethodOptionsWithSpec): apigateway.Method;
@@ -20,10 +20,10 @@ addMethod(httpMethod: string, target?: apigateway.Integration, options?: MethodO
2020
| Parameter | Type | Description |
2121
| --- | --- | --- |
2222
| httpMethod | string | |
23-
| target | apigateway.Integration | <i>(Optional)</i> |
24-
| options | [MethodOptionsWithSpec](./cdk-rest-api-with-spec.methodoptionswithspec.md) | <i>(Optional)</i> |
23+
| target | apigateway.Integration | _(Optional)_ |
24+
| options | [MethodOptionsWithSpec](./cdk-rest-api-with-spec.methodoptionswithspec.md) | _(Optional)_ |
2525

26-
<b>Returns:</b>
26+
**Returns:**
2727

2828
apigateway.Method
2929

api-docs/markdown/cdk-rest-api-with-spec.iresourcewithspec.addresource.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## IResourceWithSpec.addResource() method
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Adds a new child resource with the OpenAPI definition.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
addResource(pathPart: string, options?: ResourceOptionsWithSpec): IResourceWithSpec;
@@ -20,9 +20,9 @@ addResource(pathPart: string, options?: ResourceOptionsWithSpec): IResourceWithS
2020
| Parameter | Type | Description |
2121
| --- | --- | --- |
2222
| pathPart | string | |
23-
| options | [ResourceOptionsWithSpec](./cdk-rest-api-with-spec.resourceoptionswithspec.md) | <i>(Optional)</i> |
23+
| options | [ResourceOptionsWithSpec](./cdk-rest-api-with-spec.resourceoptionswithspec.md) | _(Optional)_ |
2424

25-
<b>Returns:</b>
25+
**Returns:**
2626

2727
[IResourceWithSpec](./cdk-rest-api-with-spec.iresourcewithspec.md)
2828

api-docs/markdown/cdk-rest-api-with-spec.iresourcewithspec.defaultmethodoptions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## IResourceWithSpec.defaultMethodOptions property
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Default method options with the OpenAPI definition.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
defaultMethodOptions?: MethodOptionsWithSpec;

api-docs/markdown/cdk-rest-api-with-spec.iresourcewithspec.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
## IResourceWithSpec interface
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
[aws\_apigateway.IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IResource.html) augmented with the features to build the OpenAPI definition.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
export interface IResourceWithSpec extends apigateway.Resource
1616
```
17-
<b>Extends:</b> apigateway.Resource
17+
**Extends:** apigateway.Resource
1818
1919
## Remarks
2020
@@ -24,13 +24,13 @@ Although this interface actually inherits [aws\_apigateway.Resource](https://doc
2424
2525
| Property | Modifiers | Type | Description |
2626
| --- | --- | --- | --- |
27-
| [defaultMethodOptions?](./cdk-rest-api-with-spec.iresourcewithspec.defaultmethodoptions.md) | | [MethodOptionsWithSpec](./cdk-rest-api-with-spec.methodoptionswithspec.md) | <b><i>(BETA)</i></b> <i>(Optional)</i> Default method options with the OpenAPI definition. |
28-
| [parentResource?](./cdk-rest-api-with-spec.iresourcewithspec.parentresource.md) | | [IResourceWithSpec](./cdk-rest-api-with-spec.iresourcewithspec.md) | <b><i>(BETA)</i></b> <i>(Optional)</i> Parent resource. |
27+
| [defaultMethodOptions?](./cdk-rest-api-with-spec.iresourcewithspec.defaultmethodoptions.md) | | [MethodOptionsWithSpec](./cdk-rest-api-with-spec.methodoptionswithspec.md) | **_(BETA)_** _(Optional)_ Default method options with the OpenAPI definition. |
28+
| [parentResource?](./cdk-rest-api-with-spec.iresourcewithspec.parentresource.md) | | [IResourceWithSpec](./cdk-rest-api-with-spec.iresourcewithspec.md) | **_(BETA)_** _(Optional)_ Parent resource. |
2929
3030
## Methods
3131
3232
| Method | Description |
3333
| --- | --- |
34-
| [addMethod(httpMethod, target, options)](./cdk-rest-api-with-spec.iresourcewithspec.addmethod.md) | <b><i>(BETA)</i></b> Adds a method with the OpenAPI definition. |
35-
| [addResource(pathPart, options)](./cdk-rest-api-with-spec.iresourcewithspec.addresource.md) | <b><i>(BETA)</i></b> Adds a new child resource with the OpenAPI definition. |
34+
| [addMethod(httpMethod, target, options)](./cdk-rest-api-with-spec.iresourcewithspec.addmethod.md) | **_(BETA)_** Adds a method with the OpenAPI definition. |
35+
| [addResource(pathPart, options)](./cdk-rest-api-with-spec.iresourcewithspec.addresource.md) | **_(BETA)_** Adds a new child resource with the OpenAPI definition. |
3636

api-docs/markdown/cdk-rest-api-with-spec.iresourcewithspec.parentresource.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
## IResourceWithSpec.parentResource property
66

7-
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
7+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
88
>
99
1010
Parent resource.
1111

12-
<b>Signature:</b>
12+
**Signature:**
1313

1414
```typescript
1515
parentResource?: IResourceWithSpec;

0 commit comments

Comments
 (0)