Closed
Description
We are trying to enforce some properties via required
together with allOf
to reuse existing definitions:
openapi: 3.0.0
info:
title: Minimal OpenAPI 3.0 with required on the same allOf
version: 1.0.0
paths:
/pets:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PetCreate'
responses:
'201':
description: Created
components:
schemas:
Pet:
type: object
properties:
id:
type: integer
name:
type: string
PetCreate:
allOf:
- $ref: '#/components/schemas/Pet'
required:
- name
But using setResolveFully(true)
, the required
attribute will get lost:
@Test
public void requiredAllResolveFully() {
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("required-anyOf.yaml", null, options);
RequestBody requestBody = openAPI.getPaths().get("/pets").getPost().getRequestBody();
Schema requestBodySchema = requestBody.getContent().get("application/json").getSchema();
assertNull(requestBodySchema.get$ref()); // has been inlined
Schema schema = requestBody.getContent().get("application/json").getSchema();
assertEquals(schema.getProperties().size(),2);
assertEquals(schema.getRequired().size(),1); // <-- FAILS, as its empty
}
Metadata
Metadata
Assignees
Labels
No labels