Skip to content

Commit

Permalink
Merge branch 'RicoSuter:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
drewfreyling authored Mar 30, 2024
2 parents 7043b52 + 9641df8 commit 9277ecd
Show file tree
Hide file tree
Showing 118 changed files with 4,609 additions and 885 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nswag.js text eol=lf
*.sass text
*.scm text
*.scss text
*.sh text
*.sh text eol=lf
*.sql text
*.styl text
*.tpl text
Expand Down
60 changes: 44 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,55 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.100
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
- name: 'Run: InstallDependencies, Compile, Test, Pack, Publish'
run: ./build.cmd InstallDependencies Compile Test Pack Publish
- name: 'Run: Compile, Test, Pack, Publish'
run: ./build.cmd Compile Test Pack Publish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: 'Publish: artifacts'
- name: 'Publish: NSwag.zip'
uses: actions/upload-artifact@v3
with:
name: NSwag.zip
path: artifacts/NSwag.zip
- name: 'Publish: NSwag.Npm.zip'
uses: actions/upload-artifact@v3
with:
name: NSwag.Npm.zip
path: artifacts/NSwag.Npm.zip
- name: 'Publish: NSwagStudio.msi'
uses: actions/upload-artifact@v3
with:
name: artifacts
path: artifacts
name: NSwagStudio.msi
path: artifacts/NSwagStudio.msi
- name: 'Publish: NuGet Packages'
uses: actions/upload-artifact@v3
with:
name: NuGet Packages
path: artifacts/*.nupkg
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Run: Compile, Test, Pack, Publish'
run: ./build.cmd Compile Test Pack Publish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
macos-latest:
name: macos-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: 'Run: Compile, Test, Pack, Publish'
run: ./build.cmd Compile Test Pack Publish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
50 changes: 35 additions & 15 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest
concurrency:
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- name: 'Allow long file path'
run: git config --system core.longpaths true
Expand All @@ -41,17 +38,40 @@ jobs:
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.100
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
- name: 'Run: Compile, Test, Pack'
run: ./build.cmd Compile Test Pack
- name: 'Publish: NSwag.zip'
uses: actions/upload-artifact@v3
with:
name: NSwag.zip
path: artifacts/NSwag.zip
- name: 'Publish: NSwag.Npm.zip'
uses: actions/upload-artifact@v3
with:
name: NSwag.Npm.zip
path: artifacts/NSwag.Npm.zip
- name: 'Publish: NSwagStudio.msi'
uses: actions/upload-artifact@v3
with:
name: NSwagStudio.msi
path: artifacts/NSwagStudio.msi
- name: 'Publish: NuGet Packages'
uses: actions/upload-artifact@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('global.json', 'src/**/*.csproj', 'src/**/package.json') }}
- name: 'Run: InstallDependencies, Compile, Test, Pack'
run: ./build.cmd InstallDependencies Compile Test Pack
name: NuGet Packages
path: artifacts/*.nupkg
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Run: Compile, Test, Pack'
run: ./build.cmd Compile Test Pack
macos-latest:
name: macos-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: 'Run: Compile, Test, Pack'
run: ./build.cmd Compile Test Pack
4 changes: 3 additions & 1 deletion src/Directory.Build.props → Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>14.0.0</VersionPrefix>
<VersionPrefix>14.0.7</VersionPrefix>

<Authors>Rico Suter</Authors>
<Copyright>Copyright © Rico Suter, 2023</Copyright>
Expand Down Expand Up @@ -31,6 +31,8 @@
<!-- reduce package size by only including english resources -->
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>

<UseArtifactsOutput>true</UseArtifactsOutput>

</PropertyGroup>

<ItemGroup>
Expand Down
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ The project combines the functionality of Swashbuckle (OpenAPI/Swagger generatio

The project is developed and maintained by [Rico Suter](http://rsuter.com) and other contributors.

**Features:**
### Features

- [Generate Swagger 2.0 and OpenAPI 3.0 specifications from C# ASP.NET (Core) controllers](https://github.com/RicoSuter/NSwag/wiki/Middlewares)
- Serve the specs via ASP.NET (Core) middleware, optionally with [Swagger UI](https://github.com/swagger-api/swagger-ui) or [ReDoc](https://github.com/Rebilly/ReDoc)
- Generate C# or TypeScript clients/proxies from these specs
- Everything can be automated via CLI (distributed via NuGet tool or build target; or NPM)
- CLI configured via JSON file or NSwagStudio Windows UI

**Ways to use the toolchain:**
### Ways to use the toolchain

- Simple to use Windows GUI, [NSwagStudio](https://github.com/RicoSuter/NSwag/wiki/NSwagStudio)
- By using the [OpenAPI or OpenAPI UI OWIN and ASP.NET Core Middlewares](https://github.com/RicoSuter/NSwag/wiki/Middlewares) (also serves the [Swagger UI](https://github.com/swagger-api/swagger-ui)) (recommended)
Expand All @@ -40,14 +40,14 @@ The project is developed and maintained by [Rico Suter](http://rsuter.com) and o
- With [ServiceProjectReference](https://github.com/RicoSuter/NSwag/wiki/ServiceProjectReference) tags in your .csproj (preview)
- In your [Azure V2 Functions](https://github.com/Jusas/NSwag.AzureFunctionsV2) (external project, might not use latest NSwag version)

**Tutorials:**
### Tutorials

- [Add NSwag to your ASP.NET Core app](https://github.com/RicoSuter/NSwag/wiki/AspNetCore-Middleware)
- [Integrate the NSwag toolchain into your ASP.NET Web API project](https://blog.rsuter.com/nswag-tutorial-integrate-the-nswag-toolchain-into-your-asp-net-web-api-project/)
- [Generate an Angular TypeScript client from an existing ASP.NET Web API web assembly](https://blog.rsuter.com/nswag-tutorial-generate-an-angular-2-typescript-client-from-an-existing-asp-net-web-api-web-assembly/)
- [Video Tutorial: How to integrate NSwag into your ASP.NET Core Web API project (5 mins)](https://www.youtube.com/watch?v=lF9ZZ8p2Ciw)

**OpenAPI/Swagger Generators:**
### OpenAPI/Swagger Generators

- ASP.NET Web API assembly to OpenAPI (supports .NET Core)
- [AspNetCoreOpenApiDocumentGenerator](https://github.com/RicoSuter/NSwag/wiki/AspNetCoreOpenApiDocumentGenerator)
Expand All @@ -59,7 +59,7 @@ The project is developed and maintained by [Rico Suter](http://rsuter.com) and o
- [TypesToOpenApiCommand](https://github.com/RicoSuter/NSwag/wiki/TypesToOpenApiCommand)
- Generates an OpenAPI specification containing only types from .NET assemblies

**Code Generators:**
### Code Generators

- **CSharp Client**
- [CSharpClientGenerator](https://github.com/RicoSuter/NSwag/wiki/CSharpClientGenerator)
Expand All @@ -68,10 +68,10 @@ The project is developed and maintained by [Rico Suter](http://rsuter.com) and o
- The generated clients can be used with full .NET, .NET Core, Xamarin and .NET Standard 1.4 in general
- **CSharp Controllers** (contract first/schema first development)
- [CSharpControllerGenerator](https://github.com/RicoSuter/NSwag/wiki/CSharpControllerGenerator)
- Generates Web API Controllers based on a OpenAPI specification (ASP.NET Web API and ASP.NET Core)
- Generates Web API Controllers based on an OpenAPI specification (ASP.NET Web API and ASP.NET Core)
- **TypeScript Client**
- [TypeScriptClientGenerator](https://github.com/RicoSuter/NSwag/wiki/TypeScriptClientGenerator)
- Generates TypeScript clients from a OpenAPI specification
- Generates TypeScript clients from an OpenAPI specification
- Available templates/supported libraries:
- JQuery with Callbacks, `JQueryCallbacks`
- JQuery with promises `JQueryPromises`
Expand All @@ -81,18 +81,18 @@ The project is developed and maintained by [Rico Suter](http://rsuter.com) and o
- Aurelia using the HttpClient from aurelia-fetch-client, `Aurelia` (based on the Fetch template)
- `Axios` (preview)
**Downloads**
### Downloads

- [Download latest **NSwagStudio MSI installer (NSwagStudio.msi)**](https://github.com/RicoSuter/NSwag/releases) (Windows Desktop application)
- [Download latest **NSwag command line tools** and NSwagStudio (NSwag.zip)](https://github.com/RicoSuter/NSwag/releases)

**NPM Packages**
### NPM Packages

- [NSwag](https://www.npmjs.com/package/nswag): Command line tools (.NET and .NET Core) distributed as NPM package

**NuGet Packages**
### NuGet Packages

Specification:
#### Specification

- **[NSwag.Core](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.Core/versions/latest)**
- The OpenAPI/Swagger reader and writer classes, see [OpenApiDocument](https://github.com/RicoSuter/NSwag/wiki/OpenApiDocument) (.NET Standard 1.0 / 2.0 and .NET 4.5)
Expand All @@ -101,7 +101,7 @@ Specification:
- **[NSwag.Annotations](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.Annotations/versions/latest)** (.NET Standard 1.0 / 2.0 and .NET 4.5)
- Attributes to decorate Web API controllers to control the OpenAPI generation

OpenAPI generation:
#### OpenAPI generation

- **[NSwag.Generation](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.Generation/versions/latest/)** (.NET Standard 1.0 / 2.0 and .NET 4.5)
- Classes to generate OpenAPI specifications
Expand All @@ -110,7 +110,7 @@ OpenAPI generation:
- **[NSwag.Generation.AspNetCore](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.Generation.AspNetCore/versions/latest)** (.NET Standard 1.6 / 2.0 and .NET 4.5.1)
- (Experimental) Classes to generate OpenAPI specifications from ASP.NET Core MVC controllers using the ApiExplorer

Code generation:
#### Code generation

- **[NSwag.CodeGeneration](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.CodeGeneration/versions/latest)** (.NET Standard 1.3 / 2.0 / .NET 4.5.1)
- Base classes to generate clients from OpenAPI specifications
Expand All @@ -119,15 +119,15 @@ Code generation:
- **[NSwag.CodeGeneration.TypeScript](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.CodeGeneration.TypeScript/versions/latest)** (.NET Standard 1.3 and .NET 4.5.1)
- Classes to generate TypeScript clients from OpenAPI specifications, see [TypeScriptClientGenerator](https://github.com/RicoSuter/NSwag/wiki/TypeScriptClientGenerator)

ASP.NET and ASP.NET Core:
#### ASP.NET and ASP.NET Core

- **[NSwag.AspNetCore](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.AspNetCore/versions/latest)** (.NET Standard 1.6 / 2.0 and .NET 4.5.1+)
- **[NSwag.AspNet.Owin](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.AspNet.Owin/versions/latest)** (.NET 4.5+)
- [ASP.NET Core/OWIN middlewares](https://github.com/RicoSuter/NSwag/wiki/Middlewares) for serving OpenAPI specifications and Swagger UI
- **[NSwag.AspNet.WebApi](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.AspNet.WebApi/versions/latest)** (.NET 4.5+)
- ASP.NET Web API filter which serializes exceptions ([JsonExceptionFilterAttribute](https://github.com/RicoSuter/NSwag/wiki/JsonExceptionFilterAttribute))

Frontends:
#### Frontends

- **[NSwag.AssemblyLoader](https://apimundo.com/organizations/nuget-org/nuget-feeds/public/packages/NSwag.AssemblyLoader/versions/latest)** (.NET Standard 1.6 / 2.0 and .NET 4.5.1):
- Classes to load assemblies in an isolated AppDomain and generate OpenAPI specs from Web API controllers
Expand All @@ -141,15 +141,17 @@ Frontends:
- **[NSwagStudio](https://chocolatey.org/packages/nswagstudio)** (Chocolatey, Windows):
- Package to install the NSwagStudio and command line tools via Chocolatey

CI NuGet Feed: https://www.myget.org/F/nswag/api/v3/index.json
#### CI NuGet Feed

https://www.myget.org/F/nswag/api/v3/index.json

The NuGet packages may require the **Microsoft.NETCore.Portable.Compatibility** package on .NET Core/UWP targets (if mscorlib is missing).

![LayerDiagram](assets/LayerDiagram.png)

### Usage in C&#35;

To register the [middlewares](https://github.com/RicoSuter/NSwag/wiki/AspNetCore-Middleware) to generate a OpenAPI spec and render the UI, register NSwag in `Startup.cs`:
To register the [middlewares](https://github.com/RicoSuter/NSwag/wiki/AspNetCore-Middleware) to generate an OpenAPI spec and render the UI, register NSwag in `Startup.cs`:

```csharp
public class Startup
Expand All @@ -167,7 +169,7 @@ public class Startup
...

app.UseOpenApi(); // serve OpenAPI/Swagger documents
app.UseSwaggerUi3(); // serve Swagger UI
app.UseSwaggerUi(); // serve Swagger UI
app.UseReDoc(); // serve ReDoc UI
}
}
Expand Down
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ $DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "STS"

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0
$env:DOTNET_NOLOGO = 1

###########################################################################
# EXECUTION
Expand Down Expand Up @@ -61,6 +60,7 @@ else {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
$env:PATH = "$DotNetDirectory;$env:PATH"
}

Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="STS"

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0
export DOTNET_NOLOGO=1

###########################################################################
# EXECUTION
Expand Down Expand Up @@ -54,6 +53,7 @@ else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
export PATH="$DOTNET_DIRECTORY:$PATH"
fi

echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
Expand Down
Loading

0 comments on commit 9277ecd

Please sign in to comment.