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
  • #1170
Closed
Open
Issue created Oct 04, 2018 by Administrator@rootContributor

[C++][Pistache-server] string with pattern (regex) is not treated

Created by: CyrilleBenard

Description

The generator does not consider the pattern "inside" a string type. I mean, when the openapi file describes the below syntax :

    type: string
    pattern: '^(pat-[0-9]+)$'

The generator does not take into account the pattern restriction. No dedicated code is generated

openapi-generator version

Current master : 3.3.1-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 1.0.0
  title: Check generation of string + pattern 
  description: Internal ref filename is check_pattern.yaml 

servers:
  - url: http://localhost:8080

paths:
  /stair1:
    post:
      summary: blabla
      operationId: check_generation
      tags:
        - Stair1
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Content'
      responses:
        '200':
          description: Expected response to a valid request
          content:
            application/json:
              schema:
                type: string
        default:
          description: Unexpected error

components:
  schemas:
    Content:
      type: string
      pattern: '^(pat-[0-9]+)$'
Command line used for generation

Generate :

openapi-generator-cli.sh generate -i ./openapi.yaml -g cpp-pistache-server -c ./config.json -o .

Compile :

g++ -c  -I./api -I./model -I./impl -Wall -g -std=c++11 -o obj/api/Stair1Api.o api/Stair1Api.cpp
Steps to reproduce

Generate & compile

Related issues/PRs

N/A

Suggest a fix/enhancement

Each variable should be validated with the pattern before any other treatment, in case there is a pattern to apply, of course. If the string (other type ?) does not match, return a dedicated HTTP error code 4xx : 412 ? 422 ? or the "generic" 400

As the pattern is regex compliant, the C++ std::regex lib may be used and the pattern transmitted as this to the std::regex_match method.

Assignee
Assign to
Time tracking