Skip to main content

5 posts tagged with "Swagger"

The Swagger API documentation framework - now known as OpenAPI.

View All Tags

Keeping front end and back end in sync with NSwag generated clients

· 6 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

For many years I've been a big fan of using NSwag to generate TypeScript and CSharp clients for APIs. I've written about it before in Generate TypeScript and CSharp clients with NSwag.

title image reading "Keeping front end and back end in sync with NSwag generated clients" with the Open API, TypeScript and C# logos

You're likely aware of the popularity of excellent projects like tRPC which provide a way to use TypeScript end-to-end. However, if you're working in a polyglot environment where your back end is written in C# or [insert other language here], and your front end is written in TypeScript, then cannot take advantage of that. However, by generating front end clients from a server's OpenAPI specs, it's possible to have integration tests that check your front end and your back end are aligned.

This post will show you how to do that using NSwag.

Swashbuckle and schemaId is already used

· 3 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

Swashbuckle can fail to generate a swagger / Open API document with the message "The same schemaId is already used...". This post explains what that means, and offers a way to work around it.

title image reading "Swashbuckle and schemaId is already used" with the Azure Static Web Apps logo and a Terry Pratchett icon by Lisa Krymova from NounProject.com

Swashbuckle & inheritance: Give. Me. The. Types

· 6 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

For API endpoints that return multiple types, you can use inheritance with Swashbuckle to get create a Swagger / Open API definition featuring the variety of available types. Serving all these types is not the default behaviour. This post shows you how to opt in.

title image reading "Swashbuckle and inheritance: Give. Me. The. Types" with Sid Swashbuckle the Pirate and Open API logos

NSwag generated C# client: Open API property name clashes and decimal types rather than double

· 10 min read
John Reilly
OSS Engineer - TypeScript, Azure, React, Node.js, .NET

NSwag is a great tool for generating client libraries in C# and TypeScript from Open API / Swagger definitions. You can face issues where Open API property names collide due to the nature of the C# language, and when you want to use decimal for your floating point numeric type over double. This post demonstrates how to get over both issues.

title image reading "NSwag generated C# client: Open API property name clashes and decimal types rather than double" with a C# logo and Open API logos