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

[Bug]: Generated name of enum type is incorrect when the attribute contains '[' or ']' characters #2090

Open
nfourneron opened this issue Aug 26, 2024 · 1 comment
Labels
bug Something isn't working priority:high

Comments

@nfourneron
Copy link

nfourneron commented Aug 26, 2024

Package name

core

Package version

11.0.4

Reproduction steps

Create an API specification (json or yaml format) containing an endpoint with a parameter whose name contains '[' or ']' character.
Example:

{
	"openapi": "3.0.0",
	"info": {
		"version": "1.0",
		"title": "ApiManagement"
	},
	"paths": {
		"/api-management/api-definitions": {
			"get": {
				"tags": [
					"ApiDefinitions"
				],
				"summary": "Get REST and SOAP APIs",
				"description": "Get the list of REST and SOAP APIs that are available for my company",
				"operationId": "get-api-management-api-definitions",
				"parameters": [
					{
						"name": "filter[protocol]",
						"in": "query",
						"description": "Filter by ApiDefinition protocol",
						"allowEmptyValue": false,
						"schema": {
							"enum": [
								"REST",
								"SOAP",
								"1AXML"
							],
							"example": "REST"
						}
					}
				]
			}
		}
	}
}

Then generate the corresponding sdk.

nx g @ama-sdk/schematics:typescript-core --specPath ./swagger.yaml

Current result

The corresponding generated type does not compile:

/** Enum filter[protocol] used in the ApiDefinitionsApi's getApiManagementApiDefinitions function parameter */
export type ApiDefinitionsApiGetApiManagementApiDefinitionsFilter[protocol]Enum = 'REST' | 'SOAP' | '1AXML';

Expected result

I would expect a file that at least compile with something like

The corresponding generated type does not compile:

/** Enum filter[protocol] used in the ApiDefinitionsApi's getApiManagementApiDefinitions function parameter */
export type ApiDefinitionsApiGetApiManagementApiDefinitionsFilterProtocolEnum = 'REST' | 'SOAP' | '1AXML';

Additional comments

According to the Open API guide, it does not seem forbidden to use '[' or ']' special characters in the attribute name
image

@nfourneron nfourneron added bug Something isn't working triage labels Aug 26, 2024
@kpanot
Copy link
Contributor

kpanot commented Aug 26, 2024

Relative to issue #640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:high
Projects
None yet
Development

No branches or pull requests

3 participants