OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the python-flask generator, string regex patterns have forward slashes somehow additionally escaped, changing the meaning of the pattern.
I found this bug that seems related. Seems like a reoccurrence.
Generated line:
Actual:
if bar is not None and not re.search(r'^foo\\/bar$', bar): # noqa: E501
Expected:
if bar is not None and not re.search(r'^foo\/bar$', bar): # noqa: E501
With the current implementation, the input body "{"bar": "foo/bar"} passes the jsonschema validation (as it should), but then the model conversion fails with the raised ValueError, causing a 500.
openapi-generator version
Verified on 5.0.0-beta2 and 4.3.1.
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Foo API
description:
Test out deepObjects with query
version: 0.1.0
servers:
- url: 'http://localhost:8080/v1'
components:
schemas:
Foo:
type: object
properties:
bar:
type: string
pattern: '^foo\/bar$'
description:
A Foo object
paths:
/foo:
post:
operationId: CreateFoo
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
responses:
'200':
description: OK
'400':
description: Bad request
Generation Details
Steps to reproduce
Save the above yaml as openapi.yaml, then run either:
Bug Report Checklist
Description
Using the python-flask generator, string regex patterns have forward slashes somehow additionally escaped, changing the meaning of the pattern.
I found this bug that seems related. Seems like a reoccurrence.
Generated line: Actual:
Expected:
With the current implementation, the input body "{"bar": "foo/bar"} passes the jsonschema validation (as it should), but then the model conversion fails with the raised ValueError, causing a 500.
openapi-generator version
Verified on 5.0.0-beta2 and 4.3.1.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Save the above yaml as
openapi.yaml
, then run either:or
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/1823
Suggest a fix
I suspect something somewhere around here or the base class, since that is what the referenced bug added, but I can't quite seem to figure out what.