Open sebapala-neta opened 4 years ago
Maybe this helps: https://github.com/RicoSuter/NJsonSchema/wiki/Inheritance
Or maybe you can add multiple OpenApiReponse attributes
Nop, sorry for my english i try explain my problem.
I have this:
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
/// <summary>
/// Lista de mascotas
/// </summary>
public List<Pet> Pets { get; set; }
}
/// <summary>
/// Clase generica de mascota
/// </summary>
public abstract class Pet
{
/// <summary>
/// Nombre
/// </summary>
public string Name { get; set; }
}
/// <summary>
/// Perro
/// </summary>
public class Dog : Pet
{
/// <summary>
/// Edad
/// </summary>
public int Age { get; set; }
}
/// <summary>
/// Gato
/// </summary>
public class Cat : Pet
{
/// <summary>
/// Color
/// </summary>
public string Color { get; set; }
}
And I want a yaml file like this:
Product:
type: object
properties:
Id:
description: Id
type: integer
format: int32
Name:
description: name of product
type: string
Pets:
description: List of Pets
anyOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
Thanks in advance
With this code the generator cannot know what implementations exist and there is no discriminator to deserialize. Did you read this link?
Yeap, i read your link, But i want generate documentation from c# comments in code, this is my problem.
I am implementing nswag to create swagger.json from the xml documentation of a webapi c # project.
But I can't get an anyOf object like the following to be returned:
`Reservations: description: Lista de reservas incluidas en el itinerario anyOf:
How can I achieve this? Sorry for my English