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

Nestia swagger generates incorrect schema when using EncryptedRoute with @nestjs/cache-manager #864

Closed
honguyenhaituan opened this issue Apr 11, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@honguyenhaituan
Copy link

Summary

Nestia swagger generates incorrect schema when using EncryptedRoute with @nestjs/cache-manager

When I use cache interceptor in a controller like this

@EncryptedRoute.Get()
@UseInterceptors(CacheInterceptor)
async getGames(@TypedQuery() query: GetGamesQuery): Promise<GetGamesResponse> {}

the swagger generate not contain information about encrypted route:

"/api/games": {
	"get": {
		"tags": ["games"],
		"operationId": "getGames",
		"parameters": [
			{
				"name": "query",
				"in": "query",
				"schema": {
					"$ref": "#/components/schemas/GetGamesQuery"
				},
				"description": "",
				"required": true
			}
		],
		"responses": {
			"200": {
				"description": "",
				"content": {
					"application/json": {
						"schema": {
							"$ref": "#/components/schemas/GetGamesResponse"
						}
					}
				}
			}
		}
	}
},

but when I change the order of decorator like this every thing is ok

@UseInterceptors(CacheInterceptor)
@EncryptedRoute.Get()
async getGames(@TypedQuery() query: GetGamesQuery): Promise<GetGamesResponse> {}
"/api/games": {
	"get": {
		"tags": ["games"],
		"operationId": "getGames",
		"parameters": [
			{
				"name": "query",
				"in": "query",
				"schema": {
					"$ref": "#/components/schemas/GetGamesQuery"
				},
				"description": "",
				"required": true
			}
		],
		"responses": {
			"200": {
				"description": "## Warning\n\nResponse data have been encrypted.\n\nThe response body data would be encrypted as \"AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding\", through the [EncryptedRoute.G.et](https://github.com/samchon/@nestia/core#encryptedroute) component.\n\nTherefore, just utilize this swagger editor only for referencing. If you need to call the real API, using [SDK](https://github.com/samchon/nestia#software-development-kit) would be much better.",
				"content": {
					"text/plain": {
						"schema": {
							"$ref": "#/components/schemas/GetGamesResponse"
						}
					}
				},
				"x-nestia-encrypted": true
			}
		}
	}
},
@honguyenhaituan
Copy link
Author

I think it because this line

const encrypted: boolean =
Reflect.getMetadata(Constants.INTERCEPTORS_METADATA, proto)?.[0]
?.constructor?.name === "EncryptedRouteInterceptor";

@samchon
Copy link
Owner

samchon commented Apr 18, 2024

Good, I will patch it.

@samchon samchon self-assigned this Apr 18, 2024
@samchon samchon added the bug Something isn't working label Apr 18, 2024
samchon added a commit that referenced this issue Apr 18, 2024
Fix #864: exact @EncryptedRoute() tracing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants