Path parameter with ref schema does not work
Issue #392
new
swagger-request-validator-core version 2.28.2.
Validator configuration:
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolve(true);
parseOptions.setResolveFully(false);
parseOptions.setResolveCombinators(true);
LevelResolver levelResolver = LevelResolver.create()
.withLevel("validation.schema.additionalProperties", IGNORE)
.build();
OpenAPI openApi = loadOpenApi(parseOptions);
OpenApiInteractionValidator.Builder builder = OpenApiInteractionValidator
.createFor(openApi)
.withParseOptions(parseOptions)
.withLevelResolver(levelResolver);
OpenApi:
---
openapi: 3.0.3
info:
title: ref error
version: v1
security:
- bearerAuth: []
paths:
/valuation/{byIdType}/{id}:
get:
operationId: getValuations
parameters:
- name: byIdType
in: path
required: true
schema:
$ref: '#/components/schemas/FindByIdType'
- name: id
in: path
description: Id
required: true
schema:
type: string
responses:
"200":
description: Valuations
"400":
description: Invalid input
"404":
description: Car not found
components:
schemas:
FindByIdType:
description: The possible identifiers types
enum:
- ID_1
- ID_2
type: string
Making a GET request to /valuation/ID1/1337 results in the following error:
"messages": [
{
"key": "validation.request.parameter.schema.invalidJson",
"level": "ERROR",
"message": "Unable to parse JSON - Unrecognized token 'ID_1': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"ID_1\"; line: 1, column: 14].",
"context": {
"requestPath": "/valuation/ID_1/1337",
"parameter": {
"name": "byIdType",
"in": "path",
"required": true,
"style": "SIMPLE",
"explode": false,
"schema": {
"$ref": "#/components/schemas/FindByIdType",
"exampleSetFlag": false
}
},
"location": "REQUEST",
"requestMethod": "GET"
}
}
]
}