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
  • #1823
Closed
Open
Issue created Jan 05, 2019 by Administrator@rootContributor

[BUG] Python pattern re.search('r incorrect in generated server model

Created by: nathan5280

Generators aren't consistently escaping the regex patterns for python and python-flask.

Description

openapi-codegen python and python-flask generate different regex escapes.

Generated Client

        if business_addr_zip is not None and not re.search(r'^\d{5}(?:[-\s]\d{4})?$', business_addr_zip):  # noqa: E501

Generated Server

        if business_addr_zip is not None and not re.search(r'^\\d{5}(?:[-\\s]\\d{4})?$', business_addr_zip):  # noqa: E501

The client seems fine, but the server is double escaped.

openapi-generator version

docker image https://hub.docker.com/r/openapitools/openapi-generator-cli/

OpenAPI declaration file content or url

Specification:

    PlaceQuery:
      properties:
        data:
          properties:
            entity_name:
              type: string
            physical_address:
              properties:
                business_addr_zip:
                  pattern: ^\d{5}(?:[-\s]\d{4})?$
                  type: string
              required:
                - business_addr_zip
              type: object
          required:
            - entity_name
            - physical_address
          type: object
      required:
        - data
      type: object
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking