swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
When merging two OpenAPI documents into one using the maven plugin, any field that has a pattern with escape characters has the backslash ('\') duplicated in the resulting file. For example, when combining two files, one with paths and the other with components, given the following component:
Problem:
type: object
description: An RFC7807 problem object.
properties:
type:
type: string
description: A URI reference [RFC3986] that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]). When this member is not present, its value is assumed to be "about:blank".
pattern: '^((?![\|\=\;])[\p{L}\p{N}\p{M}\p{P}\p{Zs}])*$'
title:
type: string
description: A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).
pattern: '^((?![\|\=\;])[\p{L}\p{N}\p{M}\p{P}\p{Zs}])*$'
status:
type: integer
description: The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.
minimum: 100
maximum: 599
detail:
type: string
description: A human-readable explanation specific to this occurrence of the problem.
pattern: '^((?![\|\=\;])[\p{L}\p{N}\p{M}\p{P}\p{Zs}])*$'
instance:
type: string
description: A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
pattern: '^((?![\|\=\;])[\p{L}\p{N}\p{M}\p{P}\p{Zs}])*$'
The resulting component in the merged file looks like this, with all the backslashed in the pattern attribute duplicated:
Problem:
type: object
properties:
type:
pattern: "^((?![\\|\\=\\;])[\\p{L}\\p{N}\\p{M}\\p{P}\\p{Zs}])*$"
type: string
description: "A URI reference [RFC3986] that identifies the problem type.\
\ This specification encourages that, when dereferenced, it provide human-readable\
\ documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]).\
\ When this member is not present, its value is assumed to be \"about:blank\"\
."
title:
pattern: "^((?![\\|\\=\\;])[\\p{L}\\p{N}\\p{M}\\p{P}\\p{Zs}])*$"
type: string
description: "A short, human-readable summary of the problem type. It SHOULD\
\ NOT change from occurrence to occurrence of the problem, except for\
\ purposes of localization (e.g., using proactive content negotiation;\
\ see [RFC7231], Section 3.4)."
status:
maximum: 599
minimum: 100
type: integer
description: "The HTTP status code ([RFC7231], Section 6) generated by the\
\ origin server for this occurrence of the problem."
detail:
pattern: "^((?![\\|\\=\\;])[\\p{L}\\p{N}\\p{M}\\p{P}\\p{Zs}])*$"
type: string
description: A human-readable explanation specific to this occurrence of
the problem.
instance:
pattern: "^((?![\\|\\=\\;])[\\p{L}\\p{N}\\p{M}\\p{P}\\p{Zs}])*$"
type: string
description: A URI reference that identifies the specific occurrence of
the problem. It may or may not yield further information if dereferenced.
description: An RFC7807 problem object.
Create 2 OpenAPI 3 documents, one with an endpoint that references the Problem schema above, the other with the components/schema section containing the Problem definition.
Change the inputSpec configuration parameter in the plugin to point to the first API file you've created.
Execute mvn clean package on the project.
Suggest a fix/enhancement
Don't alter anything in the source files when merging them together.
Description
When merging two OpenAPI documents into one using the maven plugin, any field that has a
pattern
with escape characters has the backslash ('\') duplicated in the resulting file. For example, when combining two files, one with paths and the other with components, given the following component:The resulting component in the merged file looks like this, with all the backslashed in the
pattern
attribute duplicated:Swagger-codegen version
3.0.42
Swagger declaration file content or url
Configuration in pom.xml used for generation:
Steps to reproduce
Problem
schema above, the other with thecomponents/schema
section containing theProblem
definition.inputSpec
configuration parameter in the plugin to point to the first API file you've created.mvn clean package
on the project.Suggest a fix/enhancement
Don't alter anything in the source files when merging them together.