I have a model that's being used by one of the other models, that is being accepted as a parameter to one of my controllers. So as a result, this model is being displayed in Swagger UI. This model is a nullable type and is optional and I want to hide it from my documentation.
public class A
{
public string SomeProperty { get; set; }
public B? ClassB {get; set; }
}
public class B
{
public int SomeIntProperty { get; set; }
public bool SomeBooleanProperty { get; set; }
}
in the controller method:
public async Task<ActionResult<SomeType>> GetSomeType(A modelA, CancellationToken token)
As is, this endpoint will accept a JSON document like:
{
"SomeProperty": "SomeValue"
}
And won't need B to be present. So as a result, I want to hide B
from my Swagger schemas. How can I do that? I found some related questions/answers but all of them are about hiding properties, https://stackoverflow.com/a/48454933/16749442
Hiding all properties of a model results in empty model: