Skip to content

deck file openapi2kong incorrectly limits path parameter names to 32 characters or less #2056

@WillGunn

Description

@WillGunn

Issue:

While running deck file openapi2kong we receive an error message about a path parameter name being too long. The openapi v3.0.x specification does not say there is a limit on path parameter name lengths (see here for the specification https://swagger.io/specification/v3/#:~:text=REQUIRED.%20The%20name%20of%20the%20parameter. )

Reproduction:

Example spec file:

{
    "openapi": "3.0.4",
    "info": {
        "title": "Swagger Kong Deck openapi2kong parameter name length bug example - OpenAPI 3.0",
        "description": "Kong Deck openapi2kong parameter name length bug example",
        "version": "1.0.12"
    },
    "tags": [
        {
            "name": "pet",
            "description": "Everything about your Pets"
        }
    ],
    "paths": {
        "/pet/{thisParmeterNameIs34CharactersLong}": {
            "get": {
                "tags": [
                    "pet"
                ],
                "summary": "Find pet by ID.",
                "description": "Returns a single pet.",
                "operationId": "getPetById",
                "parameters": [
                    {
                        "name": "thisParmeterNameIs34CharactersLong",
                        "in": "path",
                        "description": "ID of pet to return",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Pet"
                                }
                            },
                            "application/xml": {
                                "schema": {
                                    "$ref": "#/components/schemas/Pet"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid ID supplied"
                    },
                    "404": {
                        "description": "Pet not found"
                    },
                    "default": {
                        "description": "Unexpected error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "api_key": []
                    },
                    {
                        "petstore_auth": [
                            "write:pets",
                            "read:pets"
                        ]
                    }
                ]
            }
        }
    },
    "components": {
        "schemas": {
            "Pet": {
                "required": [
                    "name",
                    "photoUrls"
                ],
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "format": "int64",
                        "example": 10
                    },
                    "name": {
                        "type": "string",
                        "example": "doggie"
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "string"
                    },
                    "message": {
                        "type": "string"
                    }
                },
                "required": [
                    "code",
                    "message"
                ]
            }
        },
        "securitySchemes": {
            "petstore_auth": {
                "type": "oauth2",
                "flows": {
                    "implicit": {
                        "authorizationUrl": "https://petstore3.swagger.io/oauth/authorize",
                        "scopes": {
                            "write:pets": "modify pets in your account",
                            "read:pets": "read your pets"
                        }
                    }
                }
            },
            "api_key": {
                "type": "apiKey",
                "name": "api_key",
                "in": "header"
            }
        }
    }
}

Command and error:

deck file openapi2kong --spec .\swagger\internal_v2.json --output-file internal_v2_kong.json --format json
Error: failed converting OpenAPI spec '.swagger\internal_v2.json'; path-parameter name exceeds 32 characters: 'thisParmeterNameIs34CharactersLong' (sanitized to 'thisParmeterNameIs34CharactersLong')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions