Skip to content

Commit d10f308

Browse files
committed
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 4e90655 commit d10f308

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

src/schema-routes/schema-routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class SchemaRoutes {
110110
originalRouteName;
111111

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

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

tests/spec/extractRequestParams/expected.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,31 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
472472
...params,
473473
}),
474474
};
475+
iKey = {
476+
/**
477+
* @description Get public details of an Authentiq ID.
478+
*
479+
* @tags key, get
480+
* @name IKeyDetail
481+
* @request GET:/i_key/{i_PK}
482+
*/
483+
iKeyDetail: (iPk: string, params: RequestParams = {}) =>
484+
this.request<
485+
{
486+
/** @format date-time */
487+
since?: string;
488+
status?: string;
489+
/** base64safe encoded public signing key */
490+
sub?: string;
491+
},
492+
Error
493+
>({
494+
path: `/i_key/${iPk}`,
495+
method: "GET",
496+
format: "json",
497+
...params,
498+
}),
499+
};
475500
login = {
476501
/**
477502
* @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"],

tests/spec/extractRequestParams/schema.ts

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

0 commit comments

Comments
 (0)