Giter Club home page Giter Club logo

swashbuckle.autorestextensions's Introduction

Swashbuckle.AutoRestExtensions

Build status For C# developers

Nuget Package

See https://www.nuget.org/packages/Swashbuckle.AutoRestExtensions/

Install-Package Swashbuckle.AutoRestExtensions

Starting version 5.6.0, version of this package will follow SwachBuckle version

Requirements

Install Autorest

	npm install -g autorest

How to use

Swagger.config

GlobalConfiguration.Configuration
	.EnableSwagger(
		c =>
		{
			c.SingleApiVersion("v1", "Web Api");
			c.ApplyAutoRestFilters(
				new SwaggerDocsConfigExtensionsConfiguration()
				{
					ApplyEnumTypeSchemaFilter = true,
					ApplyNullableTypeSchemaFilter = true,
					ApplyNonNullableAsRequiredSchemaFilter = true
				},
				null);
			c.DescribeAllEnumsAsStrings(true);
		})
	.EnableSwaggerUi();

Some explanations

NullableTypeSchemaFilter

This Filter will apply the x-nullable attributes in the generated JSON, x-nullable is handled poorly in V 0.17.3 of Autorest so this is why I recommend using nightly. If you don't want to use nightly build you may end up having your complex property like SomeDto.List<Guid> generated as SomeDto.List<Guid?>. See Azure/autorest#1578 for more information about Enumerable being generated with nullable properties.

NonNullableAsRequiredSchemaFilter

This looks at the schema for the x-nullable property and if the property is marked as x-nullable = false, it add the property in the required array which will be validation against null when generated back to C#.

How to build

  1. Compile the code with Visual Studio 2017

How to pack

  1. Run the following command in VS console
Nuget Pack .\Swashbuckle.AutoRestExtensions\Swashbuckle.AutoRestExtensions.csproj -IncludeReferencedProjects

Feel free to contribute

Disclaimer

This work is a fork of @gitfool. See : https://github.com/gitfool/Swashbuckle/tree/autorest-extensions


swashbuckle.autorestextensions's People

Contributors

alegrowin avatar

Stargazers

 avatar Victor Usoltsev avatar Flo avatar Michael Denny avatar jian玄冰 avatar Lulus Young avatar Nikolay Velizhanin avatar

Watchers

James Cloos avatar  avatar

Forkers

badabum

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.