Git Product home page Git Product logo

gl-swashbuckle's Introduction

NuGet Version NuGet Version Build Status

Geek Learning Swashbuckle Extensions

This project provides extensions and tools for Swashbuckle in an ASP.NET Core application.

GeekLearning.SwashbuckleExtensions

Operation Filters

  • AssignExamples: add examples in your generated Swagger file
  • AssignSecurityRequirements: add security requirements based on your ASP.NET security attributes
  • DropTextPlainConsumes: delete the text/plain content type from the consumes operation list
  • DropTextPlainProduces: delete the text/plain content type from the produces operation list
  • FormFileOperationFilter: detect IFormFile parameters to properly set the Swagger parameter type
  • SwaggerFormOperationFilter: read SwaggerFormParameter attributes allowing you to specify additional elements not necesseraly present in the ApiDescription.

Document Filters

  • SchemesDocumentFilter: apply selected schemes to the Swagger document

GeekLearning.DotNet.Swashbuckle

Name

dotnet-swashbuckle - Generate a Swagger JSON file for an offline ASP.NET Core project.

Synopsis

dotnet swashbuckle [-p|--project] [-so|--swagger-output] [-f|--framework] [-c|--configuration] [-sv|--swagger-api-version] [-h|--help] [--version]

Description

The dotnet swashbuckle command allows you to extract a Swagger file from an ASP.NET Core application without having to run it.

It can be useful if you want to build and deploy client librairies during your CI builds.

Options

-p|--project <project>

The project to target (defaults to the project in the current directory). Can be a path to a csproj file or a project directory. The targeted project must be an ASP.NET Core application, with a Startup class and with the Swashbuckle.AspNetCore services registered.

-f|--framework <framework>

Compiles for a specific framework. The framework must be defined in the project file.

-c|--configuration <configuration>

Defines the build configuration. If omitted, the build configuration defaults to Debug. Use Release build a Release configuration.

-so|--swagger-output <swagger_output_file>

File in which to write Swagger schema.

-sv|--swagger-api-version <api_version>

The API version you want to generate Swagger definition for.

--version

Show version information.

-h|--help

Show help information.

Examples

Write a swagger.json file in the current directory, which is an ASP.NET Core application:

dotnet swashbuckle

Write a my-swagger.json file in the current directory, which is an ASP.NET Core application, that contains the v1 API definition:

dotnet swashbuckle -sv v1 -so my-swagger.json

Write a result.json file in the src/MyWebApp directory, which is an ASP.NET Core application, compiled for the net462 framework in Release configuration, that contains the v1 API definition:

dotnet swashbuckle -p src/MyWebApp -f net462 -c Release -so result.json -sv v1

gl-swashbuckle's People

Contributors

asiffermann avatar sandorfr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

minuz

gl-swashbuckle's Issues

Version mismatch

Hi guys,

We have been having a bit of a problem with the build server and I end up finding that there's a version mismatch between the projects.

The generated SwaggerGen project generates the following dependencies:

    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="*" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="*" />
    <PackageReference Include="System.Runtime.Loader" Version="*" />

When I checked which version that would restore, it showed as everything as latest version.
Then on GeekLearning.DotNet.Swashbuckle I modified to the following.

    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" /> -- Old
    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.1" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" /> --Old
    <PackageReference Include="Swashbuckle.AspNetCore" Version="2.2.0" />

This seems to work...but I cannot confirm if that's the actual fix for the problem I have until I run on build server. Could you guys have a look? I can submit a pull request with those changes if necessary.

Cheers

Error with Microsoft.AspNetCore.TestHost 3.0.0

I have an application that uses .Net Core 2.1. When I run dotnet swashbuckle, I get the following error:

... SwaggerGen\SwaggerGen.csproj : NU1202: Package.Microsoft.AspNetCore.TestHost 3.0.0 is not compatible with netcoreapp2.1 ...

I assume this breaks with the release of .Net Core 3.0. Is there a way to specify the version of TestHost to use?

TargetFramework flexibility

Instead of having hardcoded TargetFramework in the project template, we should sniff it from the project the tool is being run for.

Settings Management

Currently there's no way to easily inject configuration settings. It can lead to early crash of the underlying web app just because it does not have any of the required settings.

Batch generation --all-documents

Have a --all-documents switch to actually output all swagger documents or make it the default behavior when no document is specified instead of using the default v1 value. This would allow users to output all their swagger api documents at once.

By the way --swagger-api-version might not be the right name and may be benefit from being renamed to --swagger-document as some people might split their API accross different files, for instance some API might be targeted at different audience and one might want to generated clients/documents scoped on a specific API area.

Improve Error handling

Currently if something is wrong the tools tends to crash. We should have a better behavior for common scenarios, eg:

  • Unknown Swagger Document : likely to be a wrong version.

Improve output logs

Currently output logs are a bit confusing. It prints nothing while it's generating the wrapper project. then prints the dotnet restore and dotnet run.

  • Make donet restore / dotnet run logging part of a verbose mode
  • Display information about what the tool is actually doing
  • Display version of the tool before anything else.

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.