Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5973
Closed
Open
Issue created Apr 17, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG][typescript-axios] pattern data gets improperly escaped

Created by: n0idea

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue? Check below

  • Have you validated the input using an OpenAPI validator (example)? Yes

  • What's the version of OpenAPI Generator used? 4.3.1

  • Have you search for related issues/PRs? Yes

  • What's the actual output vs expected output?

  • Example {{{pattern}}} is /\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+/ {{{pattern}}} should be /\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+/

Description

While generating a typescript-axios client, pattern property gets improperly escaped, resulting in a non-valid regular expression. This seems to be caused by toRegularExpression(String pattern)method calling escapeText(String input): overriding the method for TypeScriptAxiosClientCodegen and removing escapeText() call fixes it (I'm raising a PR for this).

openapi-generator version

openapi-generator-cli 4.3.1-SNAPSHOT commit : cb50ad59 built : 2020-04-17T20:52:08+02:00 source : https://github.com/openapitools/openapi-generator docs : https://openapi-generator.tech/

OpenAPI declaration file content or url

Here's a minimal spec to reproduce the issue:

{
  "openapi": "3.0.1",
  "info": {
    "title": "[...]",
    "version": "1.0.0"
  },
  "paths": {
    "/account/register": {
      "post": {
        "tags": [
          "Account"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Register"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/Register"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/Register"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Register": {
        "required": [
          "Email",
          "Password"
        ],
        "type": "object",
        "properties": {
          "Email": {
            "pattern": "\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+",
            "type": "string"
          },
          "Password": {
            "pattern": "(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[#$^+=!*()@%&]).{6,}",
            "type": "string"
          }
        }
      }
    }
  }
}

Command line used for generation

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i <...> -g typescript-axios -o test/client -t ./

Assignee
Assign to
Time tracking