Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilized v4 of Functions #111

Merged
merged 5 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

OpenAPI 2/3 implementation based on Swashbuckle(Swagger) tooling for API's built with Azure Functions

This product aims to easily provide Swagger and Swagger UI of APIs created in Azure Functions
This product aims to easily provide Swagger and Swagger UI of APIs created in Azure Functions using isolated worker model


------------------------------
4.0.1-beta

- Fixed some minor issues
- Updated to new language features
- Added exception handling and nullability
- Doocumenation fixes

------------------------------
4.0.0-beta
Expand Down
55 changes: 55 additions & 0 deletions StyleCop.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="StyleCopeRules" Description="StyleCopeRules custom ruleset" ToolsVersion="17.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1804" Action="Error" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="CS8618" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="CA1056" Action="None" />
<Rule Id="CS0169" Action="Error" />
<Rule Id="CS1591" Action="None" />
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1002" Action="Error" />
<Rule Id="SA1005" Action="None" />
<Rule Id="SA1010" Action="Error" />
<Rule Id="SA1028" Action="None" />
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1120" Action="Error" />
<Rule Id="SA1121" Action="None" />
<Rule Id="SA1123" Action="Error" />
<Rule Id="SA1129" Action="Error" />
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1202" Action="Error" />
<Rule Id="SA1204" Action="Error" />
<Rule Id="SA1208" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1300" Action="None" />
<Rule Id="SA1303" Action="Error" />
<Rule Id="SA1306" Action="Error" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1310" Action="None" />
<Rule Id="SA1401" Action="Error" />
<Rule Id="SA1413" Action="None" />
<Rule Id="SA1500" Action="Error" />
<Rule Id="SA1502" Action="Error" />
<Rule Id="SA1507" Action="Error" />
<Rule Id="SA1508" Action="Error" />
<Rule Id="SA1512" Action="Error" />
<Rule Id="SA1513" Action="None" />
<Rule Id="SA1515" Action="None" />
<Rule Id="SA1516" Action="None" />
<Rule Id="SA1518" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1602" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1652" Action="None" />
<Rule Id="CA2017" Action="None" />
<Rule Id="SA1618" Action="None" />
<Rule Id="CS0168" Action="None" />
<Rule Id="SA1629" Action="None" />
<Rule Id="SA1642" Action="None" />
</Rules>
</RuleSet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestVarOrType_005FBuiltInTypes/@EntryIndexedValue">DO_NOT_SHOW</s:String></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,72 @@ namespace AzureFunctions.Extensions.Swashbuckle.Attribute
{
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
public class QueryStringParameterAttribute : System.Attribute

{
public QueryStringParameterAttribute(string name, string description)
{
Initialise(name, description);
Example = new OpenApiNull();
this.Initialize(name, description);
this.Example = new OpenApiNull();
}

public QueryStringParameterAttribute(string name, string description, string example)
{

Initialise(name, description);
DataType = typeof(string);
Example = new OpenApiString(example);
this.Initialize(name, description);
this.DataType = typeof(string);
this.Example = new OpenApiString(example);
}

public QueryStringParameterAttribute(string name, string description, int example)
{
Initialise(name, description);
DataType = typeof(int);
Example = new OpenApiInteger(example);
this.Initialize(name, description);
this.DataType = typeof(int);
this.Example = new OpenApiInteger(example);
}

public QueryStringParameterAttribute(string name, string description, long example)
{

Initialise(name, description);
DataType = typeof(long);
Example = new OpenApiLong(example);
this.Initialize(name, description);
this.DataType = typeof(long);
this.Example = new OpenApiLong(example);
}

public QueryStringParameterAttribute(string name, string description, double example)
{
Initialise(name, description);
Example = new OpenApiDouble(example);
this.Initialize(name, description);
this.Example = new OpenApiDouble(example);
}

public QueryStringParameterAttribute(string name, string description, float example)
{
Initialise(name, description);
DataType = typeof(float);
Example = new OpenApiFloat(example);
this.Initialize(name, description);
this.DataType = typeof(float);
this.Example = new OpenApiFloat(example);
}

public QueryStringParameterAttribute(string name, string description, byte example)
{
Initialise(name, description);
DataType = typeof(byte);
Example = new OpenApiByte(example);
this.Initialize(name, description);
this.DataType = typeof(byte);
this.Example = new OpenApiByte(example);
}

public QueryStringParameterAttribute(string name, string description, bool example)
{
Initialise(name, description);
DataType = typeof(bool);
Example = new OpenApiBoolean(example);
this.Initialize(name, description);
this.DataType = typeof(bool);
this.Example = new OpenApiBoolean(example);
}

private void Initialise(string name, string description)
private void Initialize(string name, string description)
{
Name = name;
Description = description;
this.Name = name;
this.Description = description;
}

#region public properties

public string Name { get; set; }
public Type DataType { get; set; }
public string Description { get; set; }
public bool Required { get; set; } = false;
public IOpenApiAny Example { get; }

#endregion

}

}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;

namespace AzureFunctions.Extensions.Swashbuckle.Attribute
Expand All @@ -16,18 +16,18 @@ public class RequestBodyTypeAttribute : System.Attribute
/// <param name="description">Model description</param>
public RequestBodyTypeAttribute(Type bodyType, string description)
{
Type = bodyType;
Description = description;
this.Type = bodyType;
this.Description = description;
}

/// <summary>
/// Body model type
/// Gets Body model type
/// </summary>
public Type Type { get; }

/// <summary>
/// Body model description
/// Gets Body model description
/// </summary>
public string Description { get; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace AzureFunctions.Extensions.Swashbuckle.Attribute
{
Expand All @@ -7,9 +7,9 @@ public class SwaggerUploadFileAttribute : System.Attribute
{
public SwaggerUploadFileAttribute(string name, string description, string example = "")
{
Name = name;
Description = description;
Example = example;
this.Name = name;
this.Description = description;
this.Example = example;
}

public string Name { get; }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,41 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageId>AzureExtensions.Swashbuckle</PackageId>
<Authors>vitalybibikov</Authors>
<Authors>Vitaly Bibikov</Authors>
<Description>Swagger and Swagger UI in Azure Functions by Swashbuckle</Description>
<AssemblyName>AzureFunctions.Extensions.Swashbuckle</AssemblyName>
<Version>4.0.0-beta</Version>
<Version>4.0.1-beta</Version>
<RootNamespace>AzureFunctions.Extensions.Swashbuckle</RootNamespace>
<Copyright>vitalybibikov</Copyright>
<PackageProjectUrl>https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle</PackageProjectUrl>
<RepositoryUrl>https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>Swagger Swashbuckle AzureFunctions webjobs extensions</PackageTags>
<PackageTags>Swagger Swashbuckle Azure Functions openapi openapi3 isolated worker</PackageTags>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>Open.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnablePackageValidation>true</EnablePackageValidation>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
<CodeAnalysisRuleSet>..\..\..\StyleCop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
Expand All @@ -40,6 +62,23 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Compile Remove="nupkgs\**" />
<EmbeddedResource Remove="nupkgs\**" />
<None Remove="nupkgs\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="..\..\..\stylecop.json" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\..\LICENSE">
<Pack>True</Pack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;
Expand All @@ -8,7 +6,7 @@ namespace AzureFunctions.Extensions.Swashbuckle.Settings
{
public class SwaggerDocOptions
{
public string Title { get; set; } = Assembly.GetAssembly(typeof(SwaggerDocOptions)).GetName().Name;
public string? Title { get; set; } = Assembly.GetAssembly(typeof(SwaggerDocOptions))?.GetName().Name;

public string? XmlPath { get; set; }

Expand All @@ -22,14 +20,14 @@ public class SwaggerDocOptions

public OpenApiSpecVersion SpecVersion { get; set; } = OpenApiSpecVersion.OpenApi3_0;

public Action<SwaggerGenOptions> ConfigureSwaggerGen { get; set; }
public Action<SwaggerGenOptions>? ConfigureSwaggerGen { get; set; }

public string ClientId { get; set; } = "";
public string ClientId { get; set; } = string.Empty;

public string OAuth2RedirectPath { get; set; } = "";
public string OAuth2RedirectPath { get; set; } = string.Empty;

public bool AddNewtonsoftSupport { get; set; } = false;

public string RoutePrefix { get; set; } = "";
public string RoutePrefix { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AzureFunctions.Extensions.Swashbuckle.Settings
namespace AzureFunctions.Extensions.Swashbuckle.Settings
{
public class SwaggerDocument
{
Expand All @@ -9,6 +9,5 @@ public class SwaggerDocument
public string Version { get; set; } = "v1";

public string Description { get; set; } = "Swagger document by Swashbuckle";

}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System;
using System.IO;
using System.Reflection;

namespace AzureFunctions.Extensions.Swashbuckle.SwashBuckle.Extensions
{
internal static class AssemblyExtensions
{
public static Stream GetResourceByName(this Assembly assembly, string name)
public static Stream? GetResourceByName(this Assembly assembly, string name)
{
if (assembly == null)
{
Expand Down
Loading