Skip to content

Commit f8b8d18

Browse files
ahoseiniansmorimoto
authored andcommitted
Fix route param parsing when the param begins with just one letter
For example if the param was i_key the current regex would not find it as a variable. it was only working for the params with more than one letter before either `.` `-` or `_`. the fix should allow to find params with only one letter at begninng.
1 parent 14078b5 commit f8b8d18

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

src/schema-routes/schema-routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class SchemaRoutes {
9696
originalRouteName;
9797

9898
const pathParamMatches = (routeName || "").match(
99-
/({(([A-z]){1}([a-zA-Z0-9]-?_?\.?)+)([0-9]+)?})|(:(([A-z]){1}([a-zA-Z0-9]-?_?\.?)+)([0-9]+)?:?)/g,
99+
/({(([A-z]){1}([a-zA-Z0-9-_.]-?_?\.?)+)([0-9]+)?})|(:(([A-z]){1}([a-zA-Z0-9-_.]-?_?\.?)+)([0-9]+)?:?)/g,
100100
);
101101

102102
// used in case when path parameters is not declared in requestInfo.parameters ("in": "path")

tests/spec/defaultAsSuccess/__snapshots__/basic.test.ts.snap

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,31 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
442442
...params,
443443
}),
444444
};
445+
iKey = {
446+
/**
447+
* @description Get public details of an Authentiq ID.
448+
*
449+
* @tags key, get
450+
* @name IKeyDetail
451+
* @request GET:/i_key/{i_PK}
452+
*/
453+
iKeyDetail: (iPk: string, params: RequestParams = {}) =>
454+
this.request<
455+
{
456+
/** @format date-time */
457+
since?: string;
458+
status?: string;
459+
/** base64safe encoded public signing key */
460+
sub?: string;
461+
},
462+
Error
463+
>({
464+
path: `/i_key/${iPk}`,
465+
method: "GET",
466+
format: "json",
467+
...params,
468+
}),
469+
};
445470
login = {
446471
/**
447472
* @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples

tests/spec/extractRequestParams/__snapshots__/basic.test.ts.snap

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,31 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
476476
...params,
477477
}),
478478
};
479+
iKey = {
480+
/**
481+
* @description Get public details of an Authentiq ID.
482+
*
483+
* @tags key, get
484+
* @name IKeyDetail
485+
* @request GET:/i_key/{i_PK}
486+
*/
487+
iKeyDetail: (iPk: string, params: RequestParams = {}) =>
488+
this.request<
489+
{
490+
/** @format date-time */
491+
since?: string;
492+
status?: string;
493+
/** base64safe encoded public signing key */
494+
sub?: string;
495+
},
496+
Error
497+
>({
498+
path: `/i_key/${iPk}`,
499+
method: "GET",
500+
format: "json",
501+
...params,
502+
}),
503+
};
479504
login = {
480505
/**
481506
* @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples

tests/spec/extractRequestParams/schema.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
"required": true,
5757
"type": "string"
5858
},
59+
"i_PK": {
60+
"description": "Public Signing Key - Authentiq ID (43 chars)",
61+
"in": "path",
62+
"name": "i_PK",
63+
"required": true,
64+
"type": "string"
65+
},
5966
"BarBaz": {
6067
"description": "bar baz",
6168
"in": "path",
@@ -424,6 +431,55 @@
424431
"tags": ["key", "put"]
425432
}
426433
},
434+
"/i_key/{i_PK}": {
435+
"get": {
436+
"description": "Get public details of an Authentiq ID.\n",
437+
"parameters": [
438+
{
439+
"$ref": "#/parameters/i_PK"
440+
}
441+
],
442+
"produces": ["application/json"],
443+
"responses": {
444+
"200": {
445+
"description": "Successfully retrieved",
446+
"schema": {
447+
"properties": {
448+
"since": {
449+
"format": "date-time",
450+
"type": "string"
451+
},
452+
"status": {
453+
"type": "string"
454+
},
455+
"sub": {
456+
"description": "base64safe encoded public signing key",
457+
"type": "string"
458+
}
459+
},
460+
"title": "JWT",
461+
"type": "object"
462+
}
463+
},
464+
"404": {
465+
"description": "Unknown key `unknown-key`",
466+
"schema": {
467+
"$ref": "#/definitions/Error"
468+
}
469+
},
470+
"410": {
471+
"description": "Key is revoked (gone). `revoked-key`",
472+
"schema": {
473+
"$ref": "#/definitions/Error"
474+
}
475+
},
476+
"default": {
477+
"$ref": "#/responses/ErrorResponse"
478+
}
479+
},
480+
"tags": ["key", "get"]
481+
}
482+
},
427483
"/login": {
428484
"post": {
429485
"consumes": ["application/jwt"],

0 commit comments

Comments
 (0)