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

Fix route param parsing when the param begins with just one letter #686

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/schema-routes/schema-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class SchemaRoutes {
originalRouteName;

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

// used in case when path parameters is not declared in requestInfo.parameters ("in": "path")
Expand Down
46 changes: 46 additions & 0 deletions tests/spec/extractRequestParams/expected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,52 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
...params,
}),
};
iKey = {
/**
* @description Get public details of an Authentiq ID.
*
* @tags key, get
* @name IKeyDetail
* @request GET:/i_key/{i_PK}
*/
iKeyDetail: (iPk: string, params: RequestParams = {}) =>
this.request<
{
/** @format date-time */
since?: string;
status?: string;
/** base64safe encoded public signing key */
sub?: string;
},
Error
>({
path: `/i_key/${iPk}`,
method: "GET",
format: "json",
...params,
}),

/**
* @description Get public details of an Authentiq ID.
*
* @tags key, get
* @name UnderlinesDetail
* @request GET:/i_key/underlines/{i__UK}
*/
underlinesDetail: (iUk: string, params: RequestParams = {}) =>
this.request<
{
/** base64safe encoded public signing key */
sub?: string;
},
Error
>({
path: `/i_key/underlines/${iUk}`,
method: "GET",
format: "json",
...params,
}),
};
login = {
/**
* @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples
Expand Down
93 changes: 93 additions & 0 deletions tests/spec/extractRequestParams/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
"required": true,
"type": "string"
},
"i__UK": {
"description": "Variable with double __ in it.",
"in": "path",
"name": "i__UK",
"required": true,
"type": "string"
},
"i_PK": {
"description": "Public Signing Key - Authentiq ID (43 chars)",
"in": "path",
"name": "i_PK",
"required": true,
"type": "string"
},
"BarBaz": {
"description": "bar baz",
"in": "path",
Expand Down Expand Up @@ -424,6 +438,85 @@
"tags": ["key", "put"]
}
},
"/i_key/{i_PK}": {
"get": {
"description": "Get public details of an Authentiq ID.\n",
"parameters": [
{
"$ref": "#/parameters/i_PK"
}
],
"produces": ["application/json"],
"responses": {
"200": {
"description": "Successfully retrieved",
"schema": {
"properties": {
"since": {
"format": "date-time",
"type": "string"
},
"status": {
"type": "string"
},
"sub": {
"description": "base64safe encoded public signing key",
"type": "string"
}
},
"title": "JWT",
"type": "object"
}
},
"404": {
"description": "Unknown key `unknown-key`",
"schema": {
"$ref": "#/definitions/Error"
}
},
"410": {
"description": "Key is revoked (gone). `revoked-key`",
"schema": {
"$ref": "#/definitions/Error"
}
},
"default": {
"$ref": "#/responses/ErrorResponse"
}
},
"tags": ["key", "get"]
}
},
"/i_key/underlines/{i__UK}": {
"get": {
"description": "Get public details of an Authentiq ID.\n",
"parameters": [
{
"$ref": "#/parameters/i__UK"
}
],
"produces": ["application/json"],
"responses": {
"200": {
"description": "Successfully retrieved",
"schema": {
"properties": {
"sub": {
"description": "base64safe encoded public signing key",
"type": "string"
}
},
"title": "JWT",
"type": "object"
}
},
"default": {
"$ref": "#/responses/ErrorResponse"
}
},
"tags": ["key", "get"]
}
},
"/login": {
"post": {
"consumes": ["application/jwt"],
Expand Down
46 changes: 46 additions & 0 deletions tests/spec/extractRequestParams/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,52 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
...params,
}),
};
iKey = {
/**
* @description Get public details of an Authentiq ID.
*
* @tags key, get
* @name IKeyDetail
* @request GET:/i_key/{i_PK}
*/
iKeyDetail: (iPk: string, params: RequestParams = {}) =>
this.request<
{
/** @format date-time */
since?: string;
status?: string;
/** base64safe encoded public signing key */
sub?: string;
},
Error
>({
path: `/i_key/${iPk}`,
method: "GET",
format: "json",
...params,
}),

/**
* @description Get public details of an Authentiq ID.
*
* @tags key, get
* @name UnderlinesDetail
* @request GET:/i_key/underlines/{i__UK}
*/
underlinesDetail: (iUk: string, params: RequestParams = {}) =>
this.request<
{
/** base64safe encoded public signing key */
sub?: string;
},
Error
>({
path: `/i_key/underlines/${iUk}`,
method: "GET",
format: "json",
...params,
}),
};
login = {
/**
* @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples
Expand Down