Skip to content

[C# - aspnetcore] 'pattern' specification generated code regular expression is wrong #1365

@grmcdorman

Description

@grmcdorman
Description

For a parameter specification similar to the following:

{
 "name": "ID",
  "in": "path",
  "description": "ID",
  "required": true,
  "type": "string",
  "pattern": "[0-9a-f]{8}"
}

the resulting action has a parameter decorated (correctly) with [FromRoute][Required]; however, the RegularExpression is incorrect:

[RegularExpression("/[0-9a-f]{8}/")]

The leading and trailing slashes are treated literally, i.e. they must (incorrectly) appear in the parameter value.

openapi-generator version

main; I do not know if this is a regression.

OpenAPI declaration file content or url
{
 "name": "ID",
  "in": "path",
  "description": "ID",
  "required": true,
  "type": "string",
  "pattern": "[0-9a-f]{8}"
}
Command line used for generation

java -jar "openapi-generator-cli.jar" generate -i $GenApiPath -g aspnetcore -o $CodeDirectory -c $Parameters

Steps to reproduce

Generate with the above parameter specification.

Related issues/PRs
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions