How to custom the swagger definition for a specific property?
up vote
0
down vote
favorite
My controller action return a list of Notifications. Each notification has an Entity property typed as object. Depending of a Discriminator property, Entity property can be different.
public class NotificationDto
{
public Guid? Id{ get; set; }
public string Action { get; set; }
[SwaggerCustomAttribute()]
public object Entity { get; set; }
public string Discriminator { get; set; }
public string CreatedBy { get; set; }
public string CreatedAt { get; set; }
}
So when I will open Swagger I will see the different types available.
Currently, the result is:
{
"totalCount": 0,
"groupItems": [{
"key": {},
"items": [{
"action": "string",
"entity": {},
"createdBy": "string",
"createdAt": "string",
"id": "string"
}]
}],
"hasNext": true
}
Thanks
c# .net-core swagger
add a comment |
up vote
0
down vote
favorite
My controller action return a list of Notifications. Each notification has an Entity property typed as object. Depending of a Discriminator property, Entity property can be different.
public class NotificationDto
{
public Guid? Id{ get; set; }
public string Action { get; set; }
[SwaggerCustomAttribute()]
public object Entity { get; set; }
public string Discriminator { get; set; }
public string CreatedBy { get; set; }
public string CreatedAt { get; set; }
}
So when I will open Swagger I will see the different types available.
Currently, the result is:
{
"totalCount": 0,
"groupItems": [{
"key": {},
"items": [{
"action": "string",
"entity": {},
"createdBy": "string",
"createdAt": "string",
"id": "string"
}]
}],
"hasNext": true
}
Thanks
c# .net-core swagger
Thanks @ace for the correction :)
– Cedric Arnould
Nov 20 at 20:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My controller action return a list of Notifications. Each notification has an Entity property typed as object. Depending of a Discriminator property, Entity property can be different.
public class NotificationDto
{
public Guid? Id{ get; set; }
public string Action { get; set; }
[SwaggerCustomAttribute()]
public object Entity { get; set; }
public string Discriminator { get; set; }
public string CreatedBy { get; set; }
public string CreatedAt { get; set; }
}
So when I will open Swagger I will see the different types available.
Currently, the result is:
{
"totalCount": 0,
"groupItems": [{
"key": {},
"items": [{
"action": "string",
"entity": {},
"createdBy": "string",
"createdAt": "string",
"id": "string"
}]
}],
"hasNext": true
}
Thanks
c# .net-core swagger
My controller action return a list of Notifications. Each notification has an Entity property typed as object. Depending of a Discriminator property, Entity property can be different.
public class NotificationDto
{
public Guid? Id{ get; set; }
public string Action { get; set; }
[SwaggerCustomAttribute()]
public object Entity { get; set; }
public string Discriminator { get; set; }
public string CreatedBy { get; set; }
public string CreatedAt { get; set; }
}
So when I will open Swagger I will see the different types available.
Currently, the result is:
{
"totalCount": 0,
"groupItems": [{
"key": {},
"items": [{
"action": "string",
"entity": {},
"createdBy": "string",
"createdAt": "string",
"id": "string"
}]
}],
"hasNext": true
}
Thanks
c# .net-core swagger
c# .net-core swagger
edited Nov 20 at 7:58
Ace
518219
518219
asked Nov 20 at 0:35
Cedric Arnould
326213
326213
Thanks @ace for the correction :)
– Cedric Arnould
Nov 20 at 20:20
add a comment |
Thanks @ace for the correction :)
– Cedric Arnould
Nov 20 at 20:20
Thanks @ace for the correction :)
– Cedric Arnould
Nov 20 at 20:20
Thanks @ace for the correction :)
– Cedric Arnould
Nov 20 at 20:20
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384607%2fhow-to-custom-the-swagger-definition-for-a-specific-property%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Thanks @ace for the correction :)
– Cedric Arnould
Nov 20 at 20:20