Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/honest-bears-stay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"swagger-typescript-api": patch
---

Fix query params detection on route name parsing
3 changes: 2 additions & 1 deletion src/schema-routes/schema-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ export class SchemaRoutes {
this.config.hooks.onPreBuildRoutePath(originalRouteName) ||
originalRouteName;

// TODO forbid leading symbols [\]^` in a major release (allowed yet for backwards compatibility)
const pathParamMatches = (routeName || "").match(
/({(([A-z]){1}([a-zA-Z0-9]-?_?\.?)+)([0-9]+)?})|(:(([A-z]){1}([a-zA-Z0-9]-?_?\.?)+)([0-9]+)?:?)/g,
/({[\w[\\\]^`][-_.\w]*})|(:[\w[\\\]^`][-_.\w]*:?)/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/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,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