swagger-api / swagger-api/validator-badge
Negative lookbehind pattern causes validation to fail
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 227
- Forks
- 81
- Avg merge
- 2h 3m
- Merged PRs (30d)
- 1
Description
Hello,
When adding a negative lookbehind to a regular expression in my field validation (.net core api with swashbuckle swaggerui) the resulting swagger json is marked with an "invalid" badge.
But the regexp pattern is working just fine and the swagger seems to be valid.
Even the swagger online editor is not marking it as invalid.
The problem lies in the "pattern": "^(?<![\/\. ])$"
I narrowed it down to the "<" character. removing that the json swagger validates.
of course removing it is not a solution because i need it for the negative lookbehind.
The swagger json:
{
"openapi": "3.0.1",
"info": {
"title": "API",
"version": "0.1"
},
"paths": {
"/api/v0.1/files": {
"delete": {
"tags": [
"Files"
],
"summary": "Delete",
"parameters": [
{
"name": "path",
"in": "query",
"description": "",
"schema": {
"pattern": "^(?<![\\/\\. ])$",
"type": "string"
}
}
],
"responses": {
"204": {
"description": "Success"
}
}
}
}
},
"components": {
"schemas": {
}
}
}
The message:
{
schemaValidationMessages: [
{
level: "error",
domain: "validation",
keyword: "oneOf",
message: "instance failed to match exactly one schema (matched 0 out of 2)",
schema: {
loadingURI: "#",
pointer: "/definitions/Operation/properties/parameters/items"
},
instance: {
pointer: "/paths/~1api~1v0.1~1files/delete/parameters/0"
}
}
]
}
kind regards,
Richard
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the validator result with the OpenAPI JSON and the pattern ^(?<![\\/. ])$. Trace the schema validation path for the pattern and negative lookbehind, then verify that the supplied document no longer receives an invalid badge while remaining valid in the online editor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- api, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100