NSwag
openapi-generator
Our great sponsors
NSwag | openapi-generator | |
---|---|---|
39 | 232 | |
6,437 | 19,529 | |
- | 3.1% | |
8.9 | 9.9 | |
2 days ago | 3 days ago | |
C# | Java | |
MIT License | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
NSwag
-
This week I released v2.1 of my text-templating library Weave that now uses Source Generators by default.
I'm mostly using it for C# API client generation from backend code - sort of similar to what a tool like NSwag Studio will do. I think NTypewriter has more flexibility though, and having a live view with the VS plugin makes development quick.
-
OpenAPI v4 Proposal
I find it odd that you've struggled so much with generating API clients. I've generated C# and TypeScript (Angular's HttpClient and React Query) clients for my API and never had any issues with them. With that being said, I didn't use OpenAPI's Java-based code generators and rather used ones made by third-party developers such as NSwag[0] and openapi-codegen[1].
NSwag does a wonderful job of generating TypeScript clients from OpenAPI specs. Definitely give it a shot before killing your current setup.
https://github.com/RicoSuter/NSwag (It sucks in any OpenAPI yml, not just ones from Swashbuckle/C#)
- Looking for an alternative to NSwag
-
The Typescript ecosystem is exhausting
I use this https://github.com/RicoSuter/NSwag but it's designed for .Net backends to some extent. But you can use the client generation from the command line or manually with the standalone client app.
- Code generation from Swagger specification file
-
Tool for generating example API requests and responses from OpenAPI
Here are three tools that you can use to generate example API requests and responses from OpenAPI specifications. These tools should work well even if your schemas are deeply nested: Nswag (Command Line and GUI): Nswag is a Swagger/OpenAPI toolchain for .NET, TypeScript, and other platforms. It supports code generation, client generation, and API documentation. You can use NswagStudio, which is a graphical interface, or you can use the command line tool called "NSwag.exe" for generating example API requests and responses. GitHub: https://github.com/RicoSuter/NJsonSchema NswagStudio: https://github.com/RicoSuter/NSwag/wiki/NSwagStudio Dredd (Command Line): Dredd is a language-agnostic command-line tool for validating API descriptions against backend implementations. It supports OpenAPI, Swagger, and API Blueprint formats. Dredd can generate example requests and responses and validate whether your API implementation conforms to the API description. GitHub: https://github.com/apiaryio/dredd Documentation: https://dredd.org/en/latest/ Stoplight Studio (GUI): Stoplight Studio is a modern API design and documentation platform that supports OpenAPI and JSON Schema. It allows you to create, edit, and validate OpenAPI specifications and provides a powerful visual interface for generating example API requests and responses. Website: https://stoplight.io/studio/ GitHub: https://github.com/stoplightio/studio These tools should provide you with the ability to generate example API requests and responses from your OpenAPI specifications and handle deeply nested schemas.
-
Best practices of create models for back-end commutation.
If your API exposes a Swagger definition, you can use NSwag (https://github.com/RicoSuter/NSwag) to generate the TypeScript API Client and Models for you. We found this eliminates errors due to TS and API DTOβs not matching
- In Visual Studio 2022 Is there a way to generate a function from an OpenApi yaml file
-
What class should I create to deserialize this?
There are Swagger v2/OpenAPI v3 specifications in the repository. Could you use NSwag or (if you have Visual Studio) the Connected Services tools? That'll make a client and all the necessary types for you.
openapi-generator
-
Show HN: Manage on-prem servers from my smartphone
Of course you can compile the server from source if you have Go and the OpenAPI generator JAR (https://github.com/OpenAPITools/openapi-generator?tab=readme...)
Follow these steps : https://github.com/c100k/rebootx-on-prem/blob/master/.github...
And then :
(cd ./impl/http-server-go && GOARCH=amd64 GOOS=openbsd go build -o /app/rebootx-on-prem-http-server-go-openbsd-amd64 -v)
By adapting the arch if needed. Not tested, but it should work.
-
How to Automatically Consume RESTful APIs in Your Frontend
As an alternative, you can also use the official OpenAPI Generator, which is a more generic tool supporting a wide range of languages and frameworks.
-
Building a world-class suite of SDKs is easy with Speakeasy
I trialed generating SDKs using the OpenAPI Generator package, which was largely unsatisfactory.
-
Best way to implement base class for API calls?
If Swagger/OpenAPI is available, save yourself a lot of trouble and generate the client using OpenAPI Generator. If not, use a library like RestEase to make it significantly easier to create the client.
-
Created an API using Gin, want to create sdk for him
Then you can use oapi-codegen or openapi-generator to generate the Go (or other language) SDK for it.
-
.NET Blazor
Yep. For frontend use, I think https://www.npmjs.com/package/openapi-typescript is the most widely-used/well-regarded, though https://www.npmjs.com/package/orval seems to me to have some nicer features like react-query support.
There are other options too, I'd just stay away from "_the_ openapi generator" (https://openapi-generator.tech/) which does a pretty poor job IMO.
Disclaimer: I'm the founder of a company doing SDKs commercially, but we don't focus on the frontend right now, and our free plan is still in beta.
-
Using AI To Go From JSON to API in Seconds
Now that I have a solid way to make an Open API spec and get a functioning mock server, I'd like to take it a step further and generate an SDK to call it. Many developers use SDKs to communicate with their backend services, and tools like OpenAPI Generator enable them to do so without having to manually build them. OpenAPI Generator will take an API spec and compile it down into an SDK in the language of your choice, including front-end compatible languages like typescript-fetch.
-
10 quick tips to instantly improve API design
With the development of automatic code generation tools such OpenAPI generator (https://openapi-generator.tech/), the importance of API design rather than implementation is emphasized.
-
10+ API Documentation Tools For Super Busy Developers π©βπ»
OpenAPI Generator (Free)
-
Learning Go by examples: part 11 - Generate a Go SDK (API client library) from your Go REST API
In short, OpenAPI Generator allows generation of API client librairies (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3).
What are some alternatives?
autorest - OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
oapi-codegen - Generate Go client and server boilerplate from OpenAPI 3 specifications
SvelteKit - web development, streamlined
smithy - Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
Refit - The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
django-ninja - π¨ Fast, Async-ready, Openapi, type hints based framework for building APIs
smithy-go - Smithy code generators for Go (in development)
swagger-petstore - swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
Feign - Feign makes writing java http clients easier
swagger-typescript-api - TypeScript API generator via Swagger scheme
swagger-ui - Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.