Description
When generating a TypeScript REST client, ng-openapi-gen incorrectly unencodes certain characters inside path parameters, specifically:
The generated code does:
encodeURIComponent(param)
.replace(/%3D/g, '=')
.replace(/%2C/g, ',')
.replace(/%3B/g, ';')
This makes it impossible to send valid path parameters that contain these characters.
This behavior is not compliant with OpenAPI 3.x and breaks URLs that require proper RFC 3986 encoding.
Steps to reproduce
Define a path parameter in an OpenAPI v3 document:
paths:
/items/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: string
Generate the Angular client with ng-openapi-gen.
Call the generated method with a value containing special characters:
api.getItem("abc=123");
The generated client sends:
/items/abc=123
instead of the correct:
/items/abc%3D123
Expected behavior
Path parameters must follow RFC 3986 percent-encoding rules.
The generator should not undo encoded characters.
Correct behavior:
path = path.replace('{{{paramName}}}', encodeURIComponent(param));
Actual behavior
The generator includes legacy logic that des-encodes the following characters:
This results in invalid URLs and incorrect request routing.
Root cause analysis
The logic appears to be inherited from OpenAPI v2 (Swagger 2.0) support for Matrix Parameters, where the characters ;, =, and , had special meaning.
Example of a matrix parameter URL in Swagger 2:
/cars;color=red,blue;year=2012
Because these characters were part of the syntax, Swagger code generators avoided encoding them.
However:
❗ Matrix Parameters are not supported in OpenAPI 3.x
OpenAPI 3 explicitly removes matrix parameters.
In OAS3, path parameters must behave as plain strings, fully percent-encoded.
Therefore, the current behavior is:
- Based on deprecated OAS2 logic
- Not valid in OpenAPI 3
- Breaking standard-compliant APIs
Proposed fix
Modify the template responsible for building paths (requestBuilder.handlebars) and remove the unencoding logic:
❌ Current:
encodeURIComponent(param)
.replace(/%3D/g, '=')
.replace(/%2C/g, ',')
.replace(/%3B/g, ';')
✅ Correct:
encodeURIComponent(param)
This change is fully compatible with OpenAPI 3.x
and aligns with RFC 3986 and WHATWG URL specifications.
Impact
- Cannot send valid strings as path parameters if they contain =, , or ;.
- Makes the generated client unusable for certain APIs.
- Breaks strict OAS3 compliance.
- Causes unexpected 404 errors or incorrect routing on backend frameworks.
Description
When generating a TypeScript REST client, ng-openapi-gen incorrectly unencodes certain characters inside path parameters, specifically:
The generated code does:
encodeURIComponent(param)
.replace(/%3D/g, '=')
.replace(/%2C/g, ',')
.replace(/%3B/g, ';')
This makes it impossible to send valid path parameters that contain these characters.
This behavior is not compliant with OpenAPI 3.x and breaks URLs that require proper RFC 3986 encoding.
Steps to reproduce
Define a path parameter in an OpenAPI v3 document:
paths:
/items/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: string
Generate the Angular client with ng-openapi-gen.
Call the generated method with a value containing special characters:
api.getItem("abc=123");
The generated client sends:
/items/abc=123
instead of the correct:
/items/abc%3D123
Expected behavior
Path parameters must follow RFC 3986 percent-encoding rules.
The generator should not undo encoded characters.
Correct behavior:
path = path.replace('{{{paramName}}}', encodeURIComponent(param));
Actual behavior
The generator includes legacy logic that des-encodes the following characters:
This results in invalid URLs and incorrect request routing.
Root cause analysis
The logic appears to be inherited from OpenAPI v2 (Swagger 2.0) support for Matrix Parameters, where the characters ;, =, and , had special meaning.
Example of a matrix parameter URL in Swagger 2:
/cars;color=red,blue;year=2012
Because these characters were part of the syntax, Swagger code generators avoided encoding them.
However:
❗ Matrix Parameters are not supported in OpenAPI 3.x
OpenAPI 3 explicitly removes matrix parameters.
In OAS3, path parameters must behave as plain strings, fully percent-encoded.
Therefore, the current behavior is:
Proposed fix
Modify the template responsible for building paths (requestBuilder.handlebars) and remove the unencoding logic:
❌ Current:
encodeURIComponent(param)
.replace(/%3D/g, '=')
.replace(/%2C/g, ',')
.replace(/%3B/g, ';')
✅ Correct:
encodeURIComponent(param)
This change is fully compatible with OpenAPI 3.x
and aligns with RFC 3986 and WHATWG URL specifications.
Impact