-
Notifications
You must be signed in to change notification settings - Fork 542
Closed
Description
Consider this OAS3 spec (testMinMax3.yaml):
openapi: 3.0.1
info:
title: OpenAPI Test
description: Test
license:
name: Apache-2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
servers:
- url: http://localhost:9999/v2
paths:
/ping:
post:
summary: test
description: test it
operationId: pingOp
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SomeObj'
required: true
responses:
200:
description: OK
content: {}
components:
schemas:
SomeObj:
type: string
minLength: 1
maxLength: 3
Now I can run this test:
@Test
public void testOas3() {
final OpenAPI openAPI = new OpenAPIParser().readLocation(“../testMinMax3.yaml", null, new ParseOptions()).getOpenAPI();
Schema s = openAPI.getComponents().getSchemas().get("SomeObj");
Assert.assertEquals(s.getMinLength(), Integer.valueOf(1));
Assert.assertEquals(s.getMaxLength(), Integer.valueOf(3));
}
This is fine.
Now when you do the same with OAS2, the min and max are not correctly migrated:
With this spec (testMinMax2.yaml) :
swagger: '2.0'
info:
description: 'Test'
version: 1.0.0
title: OpenAPI Test
license:
name: Apache-2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
host: petstore.swagger.io
basePath: /v2
schemes:
- http
paths:
/ping:
post:
summary: test
description: 'test it'
operationId: pingOp
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
required: true
schema:
$ref: '#/definitions/SomeObj'
responses:
'200':
description: OK
definitions:
SomeObj:
type: string
minLength: 1
maxLength: 3
This test is failing:
@Test
public void testOas2() {
final OpenAPI openAPI = new OpenAPIParser().readLocation(“../testMinMax2.yaml", null, new ParseOptions()).getOpenAPI();
Schema s = openAPI.getComponents().getSchemas().get("SomeObj");
Assert.assertEquals(s.getMinLength(), Integer.valueOf(1)); //java.lang.AssertionError: expected [1] but found [null]
Assert.assertEquals(s.getMaxLength(), Integer.valueOf(3)); //java.lang.AssertionError: expected [3] but found [null]
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels