Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

892
Vistas
ASP.NET core: NSwag vs. Swashbuckle

we're currently using Swashbuckle.AspNetCore for API documentation purpose, but when it comes to generation of client-side models (Typescript) it seems there is a major drawback of it.

As a sample, I enhanced the known ASP.NET default project (WeatherForecast) with a base class

public class InfoEntryBase    
{        
   public string Name { get; set; }
   public string Description { get; set; }
}

public class WeatherForecast : InfoEntryBase
{
   public DateTime Date { get; set; }

   public int TemperatureC { get; set; }

   public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

   public string Summary { get; set; }
}

It then exposes WeatherForecast as

WeatherForecast{
name    string
nullable: true
description string
nullable: true
date    string($date-time)
temperatureC    integer($int32)
temperatureF    integer($int32)
readOnly: true
summary string
nullable: true
}

and the inheritance gets lost. This will make it impossible to auto-generate client-side models from the server-side code as we naturally like to port the inheritance to the Typescript code.

On investigating NSwag.AspNetCore I discovered it to take care about the inheritance. It exposes:

WeatherForecast{
name    string
description string
date*   string($date-time)
temperatureC*   integer($int32)
temperatureF*   integer($int32)
summary string
}
InfoEntryBase{
name    string
description string
}

Did I overlook something regarding Swashbuckle or is there no alternative to switch from it to NSwag?

You can review the code on https://github.com/ClemensOesterle/NSwagSpike/tree/swashbuckle whereas the NSwag implementation resides in the master branch.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This solved it.

services.AddSwaggerGen(options =>
{
    options.UseAllOfForInheritance();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda