I have a simple model that has the property Agg2Id_Agg2Reference as only having a public getter yet it still shows up in the schema Post operation within Swagger UI via latest version of Swashbuckle.
The following is the model class...
public class UpdateRequest
{
private string _firstProperty;
private string _agg2_ServiceEndPoint;
private AEA.GarthApp.Service2.Agg2.ViewModels.Agg2 _agg2Id_Agg2Reference;
private AEA.GarthApp.Service2.Agg2.ViewModels.Agg2Id _agg2Id;
private AEA.GarthApp.Service1.Agg1.ViewModels.Agg1Id _agg1Id;
public void SetAgg2ServiceEndPoint(string value)
{
_agg2_ServiceEndPoint = value;
}
public void SetAgg2IdAgg2Reference(AEA.GarthApp.Service2.Agg2.ViewModels.Agg2 value)
{
_agg2Id_Agg2Reference = value;
}
[ProtoMember(1)]
public string FirstProperty
{
get => _firstProperty;
set => _firstProperty = value;
}
[ProtoMember(2)]
public string Agg2_ServiceEndPoint
{
get => _agg2_ServiceEndPoint;
}
[ProtoMember(3)]
public AEA.GarthApp.Service2.Agg2.ViewModels.Agg2 Agg2Id_Agg2Reference
{
get => _agg2Id_Agg2Reference;
}
[ProtoMember(4)]
public AEA.GarthApp.Service2.Agg2.ViewModels.Agg2Id Agg2Id
{
get => _agg2Id;
set => _agg2Id = value;
}
[ProtoMember(5)]
public AEA.GarthApp.Service1.Agg1.ViewModels.Agg1Id Agg1Id
{
get => _agg1Id;
set => _agg1Id = value;
}
}
The following is shown in Swagger UI...
NOTE 1 : I tried to decorate the property Agg2Id_Agg2Reference with and without [ ReadOnly (true)] attribute yet still I see this property show up in Swagger UI.
NOTE 2 : The string type property Agg2_ServiceEndPoint is also only a getter yet it does not show up in the UI schema (as expected).
NOTE 3 : I don't wish to decorate with JsonIgnore as I actually want this data down on the client, I just don't want to show it as a settable property in the Swagger UI schema.
How can I remove the property Agg2Id_Agg2Reference from showing up in the Swagger/OpenAPI schema and not show up in Swagger UI?
上面的类是我的代码生成器产品的输出,我刚刚意识到这个特定的命令根本不需要 Agg2Id_Agg2Reference 属性,所以不再需要这个问题的答案......也就是说我不介意了解为什么该属性出现。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.