-
Notifications
You must be signed in to change notification settings - Fork 537
Closed
Description
With this OpenAPI v2 spec:
swagger: "2.0"
info:
description: "Test"
version: "1.0.0"
title: "Swagger v2 example"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
schemes:
- "https"
- "http"
paths:
/brands/{brand-id}/stations:
get:
tags:
- Brand
summary: Returns a list of the brand's stations
operationId: getBrandStations
parameters:
- $ref: "#/parameters/brand-id"
- in: query
name: available-to-client-only
required: true
type: boolean
responses:
200:
description: OK
parameters:
brand-id:
in: path
description: this is a test
name: brand-id
required: true
type: stringWhen I parse it like this:
OpenAPIParser openApiParser = new OpenAPIParser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
SwaggerParseResult parseResult = openApiParser.readLocation(inputSpec, null, options);
for (String string : parseResult.getMessages()) {
System.err.println(string);
}I get this error:
attribute paths.'/brands/{brand-id}/stations'. Declared path parameter brand-id needs to be defined as a path parameter in path or operation level
This is wrong, because the parameter is defined.
Swagger-UI is interpreting the spec correctly:
As comparison the corresponding OpenAPI v3 spec is working fine:
openapi: 3.0.1
info:
title: Example ref param
version: '1.0'
servers:
- url: 'http://localhost:9999/'
paths:
/brands/{brand-id}/stations:
get:
tags:
- Brand
summary: Returns a list of the brand's stations
operationId: getBrandStations
parameters:
- $ref: "#/components/parameters/brand-id"
- in: query
name: available-to-client-only
required: true
schema:
type: boolean
responses:
200:
description: OK
components:
parameters:
brand-id:
in: path
required: true
name: brand-id
schema:
type: stringJFCote
Metadata
Metadata
Assignees
Labels
No labels
