Skip to content

Bug: Required param object is not marked as required #156

@hectoryo

Description

@hectoryo

So to make a simplified example, I have these 2 entities:

public class EntityA {
	@Schema(required = true)
	private String fieldA;
	//Getters and setters...
}
public class EntityB {

	@Schema(required = true)
	private String fieldB;
	
	@Schema(required = true)
	private EntityA entityA;
	//Getters and setters...
}

As you see, EntityB has 2 required atributes fieldB and entityA.

I also have this method in the controller:

	@GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" })
	public EntityB getEntityB(){
		return new EntityB();
	}

When the doc is generated, in the EntityB, only fieldB is marked as required:

         "EntityA":{
            "required":[
               "fieldA"
            ],
            "type":"object",
            "properties":{
               "fieldA":{
                  "type":"string"
               }
            }
         },
         "EntityB":{
            "required":[
               "fieldB"
            ],
            "type":"object",
            "properties":{
               "fieldB":{
                  "type":"string"
               },
               "entityA":{
                  "$ref":"#/components/schemas/EntityA"
               }
            }
         }

image

The expected behaviour is that both fieldB and entityA should be marked as required in the schema EntityB

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions