Improvements to csharp-netcore-function generator (#12183)

* improvements to csharp-netcore-function generator

* update samples

* update doc, samples
This commit is contained in:
William Cheng 2022-04-21 01:40:23 +08:00 committed by GitHub
parent 0a53232791
commit e98c054693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 1927 additions and 206 deletions

View File

@ -11,7 +11,7 @@ title: Documentation for the csharp-netcore-functions Generator
| generator type | SERVER | |
| generator language | C# | |
| generator default templating engine | mustache | |
| helpTxt | Generates an ASP.NET Core Web API server. | |
| helpTxt | Creates Azure function templates on top of the models/converters created by the C# codegens. This function is contained in a partial class. Default Get/Create/Patch/Post etc. methods are created with an underscore prefix. The assumption is that when the function is implemented, the partial class will be completed with another partial class. The implementing code should be located in a method of the same name, only without the underscore prefix. If no such method is found then the function will throw a Not Implemented exception. This setup allows the endpoints to be specified in the schema at build time, and separated from the implementing function. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.

View File

@ -50,7 +50,7 @@ public class CsharpNetcoreFunctionsServerCodegen extends AbstractCSharpCodegen {
public static final String GENERATE_BODY = "generateBody";
public static final String BUILD_TARGET = "buildTarget";
public static final String MODEL_CLASS_MODIFIER = "modelClassModifier";
public static final String TARGET_FRAMEWORK= "targetFramework";
public static final String TARGET_FRAMEWORK = "targetFramework";
public static final String FUNCTIONS_SDK_VERSION = "functionsSDKVersion";
public static final String COMPATIBILITY_VERSION = "compatibilityVersion";
@ -283,7 +283,7 @@ public class CsharpNetcoreFunctionsServerCodegen extends AbstractCSharpCodegen {
@Override
public String getHelp() {
return "Generates an ASP.NET Core Web API server.";
return "Creates Azure function templates on top of the models/converters created by the C# codegens. This function is contained in a partial class. Default Get/Create/Patch/Post etc. methods are created with an underscore prefix. The assumption is that when the function is implemented, the partial class will be completed with another partial class. The implementing code should be located in a method of the same name, only without the underscore prefix. If no such method is found then the function will throw a Not Implemented exception. This setup allows the endpoints to be specified in the schema at build time, and separated from the implementing function.";
}
@Override
@ -379,8 +379,7 @@ public class CsharpNetcoreFunctionsServerCodegen extends AbstractCSharpCodegen {
// HACK: Unlikely in the wild, but we need to clean operation paths for MVC Routing
if (operation.path != null) {
if (operation.path.startsWith("/"))
{
if (operation.path.startsWith("/")) {
operation.path = operation.path.substring(1);
}
String original = operation.path;
@ -419,10 +418,9 @@ public class CsharpNetcoreFunctionsServerCodegen extends AbstractCSharpCodegen {
continue;
}
if(consumesString.toString().isEmpty()) {
if (consumesString.toString().isEmpty()) {
consumesString = new StringBuilder("\"" + consume.get("mediaType") + "\"");
}
else {
} else {
consumesString.append(", \"").append(consume.get("mediaType")).append("\"");
}
@ -447,7 +445,7 @@ public class CsharpNetcoreFunctionsServerCodegen extends AbstractCSharpCodegen {
}
}
if(!consumesString.toString().isEmpty()) {
if (!consumesString.toString().isEmpty()) {
operation.vendorExtensions.put("x-aspnetcore-consumes", consumesString.toString());
}
}

View File

@ -21,3 +21,5 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Org.OpenAPITools.sln
src/Org.OpenAPITools/Org.OpenAPITools.csproj

View File

@ -1,51 +1,17 @@
.gitignore
Docs/PetApi.md
Docs/StoreApi.md
Docs/UserApi.md
README.md
appveyor.yml
docs/ApiResponse.md
docs/Category.md
docs/Order.md
docs/Pet.md
docs/Tag.md
docs/User.md
generatedSrc/Client/ApiClient.cs
generatedSrc/Client/ApiException.cs
generatedSrc/Client/ApiResponse.cs
generatedSrc/Client/Configuration.cs
generatedSrc/Client/ExceptionFactory.cs
generatedSrc/Client/IApiAccessor.cs
generatedSrc/Client/OpenAPIDateConverter.cs
generatedSrc/Functions/PetApi.cs
generatedSrc/Functions/PetApi.cs
generatedSrc/Functions/StoreApi.cs
generatedSrc/Functions/StoreApi.cs
generatedSrc/Functions/UserApi.cs
generatedSrc/Functions/UserApi.cs
generatedSrc/Models/ApiResponse.cs
generatedSrc/Models/Category.cs
generatedSrc/Models/Order.cs
generatedSrc/Models/Pet.cs
generatedSrc/Models/Tag.cs
generatedSrc/Models/User.cs
generatedSrc/README.md
generatedSrc/project.json
git_push.sh
src/Org.OpenAPITools/Client/ApiClient.cs
src/Org.OpenAPITools/Client/ApiException.cs
src/Org.OpenAPITools/Client/ApiResponse.cs
src/Org.OpenAPITools/Client/ClientUtils.cs
src/Org.OpenAPITools/Client/Configuration.cs
src/Org.OpenAPITools/Client/ExceptionFactory.cs
src/Org.OpenAPITools/Client/GlobalConfiguration.cs
src/Org.OpenAPITools/Client/HttpMethod.cs
src/Org.OpenAPITools/Client/IApiAccessor.cs
src/Org.OpenAPITools/Client/IAsynchronousClient.cs
src/Org.OpenAPITools/Client/IReadableConfiguration.cs
src/Org.OpenAPITools/Client/ISynchronousClient.cs
src/Org.OpenAPITools/Client/Multimap.cs
src/Org.OpenAPITools/Client/OpenAPIDateConverter.cs
src/Org.OpenAPITools/Client/RequestOptions.cs
src/Org.OpenAPITools/Client/RetryConfiguration.cs
src/Org.OpenAPITools/Models/AbstractOpenAPISchema.cs
build.bat
build.sh
src/Org.OpenAPITools/.gitignore
src/Org.OpenAPITools/Converters/CustomEnumConverter.cs
src/Org.OpenAPITools/Functions/PetApi.cs
src/Org.OpenAPITools/Functions/StoreApi.cs
src/Org.OpenAPITools/Functions/UserApi.cs
src/Org.OpenAPITools/Models/ApiResponse.cs
src/Org.OpenAPITools/Models/Category.cs
src/Org.OpenAPITools/Models/Order.cs
src/Org.OpenAPITools/Models/Pet.cs
src/Org.OpenAPITools/Models/Tag.cs
src/Org.OpenAPITools/Models/User.cs
src/Org.OpenAPITools/OpenApi/TypeExtensions.cs
src/Org.OpenAPITools/host.json
src/Org.OpenAPITools/local.settings.json

View File

@ -1 +1 @@
5.3.1-SNAPSHOT
6.0.0-SNAPSHOT

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2043
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{6C41B0FB-16DE-4E0C-9797-286D6A24F96F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C41B0FB-16DE-4E0C-9797-286D6A24F96F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C41B0FB-16DE-4E0C-9797-286D6A24F96F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C41B0FB-16DE-4E0C-9797-286D6A24F96F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C41B0FB-16DE-4E0C-9797-286D6A24F96F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,159 +1,24 @@
# Org.OpenAPITools - the C# library for the OpenAPI Petstore
# Org.OpenAPITools - Azure Functions v4 Server
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
## Run
- API version: 1.0.0
- SDK version: 1.0.0
- Build package: org.openapitools.codegen.languages.CsharpNetcoreFunctionsServerCodegen
Linux/OS X:
<a name="frameworks-supported"></a>
## Frameworks supported
- .NET Core >=1.0
- .NET Framework >=4.6
- Mono/Xamarin >=vNext
<a name="dependencies"></a>
## Dependencies
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 106.11.7 or later
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 12.0.3 or later
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.8.0 or later
- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 5.0.0 or later
The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
```
Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations
sh build.sh
```
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742).
NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406).
Windows:
<a name="installation"></a>
## Installation
Generate the DLL using your preferred tool (e.g. `dotnet build`)
Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
```csharp
using Org.OpenAPITools.Apis;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Models;
```
<a name="usage"></a>
## Usage
To use the API client with a HTTP proxy, setup a `System.Net.WebProxy`
```csharp
Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;
build.bat
```
## Run in Docker
<a name="getting-started"></a>
## Getting Started
```csharp
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Apis;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Models;
namespace Example
{
public class Example
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "http://petstore.swagger.io/v2";
// Configure OAuth2 access token for authorization: petstore_auth
config.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(config);
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
try
{
// Add a new pet to the store
Pet result = apiInstance.AddPet(pet);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling PetApi.AddPet: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
```
<a name="documentation-for-api-endpoints"></a>
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
<a name="documentation-for-models"></a>
## Documentation for Models
- [Models.ApiResponse](docs/ApiResponse.md)
- [Models.Category](docs/Category.md)
- [Models.Order](docs/Order.md)
- [Models.Pet](docs/Pet.md)
- [Models.Tag](docs/Tag.md)
- [Models.User](docs/User.md)
<a name="documentation-for-authorization"></a>
## Documentation for Authorization
<a name="api_key"></a>
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
<a name="petstore_auth"></a>
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account
- read:pets: read your pets
cd src/Org.OpenAPITools
docker build -t org.openapitools .
docker run -p 5000:8080 org.openapitools
```

View File

@ -0,0 +1,9 @@
:: Generated by: https://openapi-generator.tech
::
@echo off
dotnet restore src\Org.OpenAPITools
dotnet build src\Org.OpenAPITools
echo Now, run the following to start the project: dotnet run -p src\Org.OpenAPITools\Org.OpenAPITools.csproj --launch-profile web.
echo.

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# Generated by: https://openapi-generator.tech
#
dotnet restore src/Org.OpenAPITools/ && \
dotnet build src/Org.OpenAPITools/ && \
echo "Now, run the following to start the project: func start"

View File

@ -0,0 +1,362 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@ -0,0 +1,33 @@
using System;
using System.ComponentModel;
using System.Globalization;
using Newtonsoft.Json;
namespace Org.OpenAPITools.Converters
{
/// <summary>
/// Custom string to enum converter
/// </summary>
public class CustomEnumConverter<T> : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var s = value as string;
if (string.IsNullOrEmpty(s))
{
return null;
}
return JsonConvert.DeserializeObject<T>(@"""" + value.ToString() + @"""");
}
}
}

View File

@ -0,0 +1,108 @@
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Org.OpenAPITools.Models;
namespace Org.OpenAPITools.Functions
{
public partial class PetApi
{
[FunctionName("PetApi_AddPet")]
public async Task<ActionResult<Pet>> _AddPet([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2pet")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("AddPet");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<Pet>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_DeletePet")]
public async Task<ActionResult<>> _DeletePet([HttpTrigger(AuthorizationLevel.Anonymous, "Delete", Route = "v2pet/{petId}")]HttpRequest req, ExecutionContext context, long petId)
{
var method = this.GetType().GetMethod("DeletePet");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_FindPetsByStatus")]
public async Task<ActionResult<List<Pet>>> _FindPetsByStatus([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2pet/findByStatus")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("FindPetsByStatus");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<List<Pet>>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_FindPetsByTags")]
public async Task<ActionResult<List<Pet>>> _FindPetsByTags([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2pet/findByTags")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("FindPetsByTags");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<List<Pet>>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_GetPetById")]
public async Task<ActionResult<Pet>> _GetPetById([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2pet/{petId}")]HttpRequest req, ExecutionContext context, long petId)
{
var method = this.GetType().GetMethod("GetPetById");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<Pet>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_UpdatePet")]
public async Task<ActionResult<Pet>> _UpdatePet([HttpTrigger(AuthorizationLevel.Anonymous, "Put", Route = "v2pet")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("UpdatePet");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<Pet>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_UpdatePetWithForm")]
public async Task<ActionResult<>> _UpdatePetWithForm([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2pet/{petId}")]HttpRequest req, ExecutionContext context, long petId)
{
var method = this.GetType().GetMethod("UpdatePetWithForm");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("PetApi_UploadFile")]
public async Task<ActionResult<ApiResponse>> _UploadFile([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2pet/{petId}/uploadImage")]HttpRequest req, ExecutionContext context, long petId)
{
var method = this.GetType().GetMethod("UploadFile");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<ApiResponse>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
}
}

View File

@ -0,0 +1,64 @@
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Org.OpenAPITools.Models;
namespace Org.OpenAPITools.Functions
{
public partial class StoreApi
{
[FunctionName("StoreApi_DeleteOrder")]
public async Task<ActionResult<>> _DeleteOrder([HttpTrigger(AuthorizationLevel.Anonymous, "Delete", Route = "v2store/order/{orderId}")]HttpRequest req, ExecutionContext context, string orderId)
{
var method = this.GetType().GetMethod("DeleteOrder");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("StoreApi_GetInventory")]
public async Task<ActionResult<Dictionary<string, int>>> _GetInventory([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2store/inventory")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("GetInventory");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<Dictionary<string, int>>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("StoreApi_GetOrderById")]
public async Task<ActionResult<Order>> _GetOrderById([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2store/order/{orderId}")]HttpRequest req, ExecutionContext context, [Range(1, 5)]long orderId)
{
var method = this.GetType().GetMethod("GetOrderById");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<Order>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("StoreApi_PlaceOrder")]
public async Task<ActionResult<Order>> _PlaceOrder([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2store/order")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("PlaceOrder");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<Order>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
}
}

View File

@ -0,0 +1,108 @@
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Org.OpenAPITools.Models;
namespace Org.OpenAPITools.Functions
{
public partial class UserApi
{
[FunctionName("UserApi_CreateUser")]
public async Task<ActionResult<>> _CreateUser([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2user")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("CreateUser");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_CreateUsersWithArrayInput")]
public async Task<ActionResult<>> _CreateUsersWithArrayInput([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2user/createWithArray")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("CreateUsersWithArrayInput");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_CreateUsersWithListInput")]
public async Task<ActionResult<>> _CreateUsersWithListInput([HttpTrigger(AuthorizationLevel.Anonymous, "Post", Route = "v2user/createWithList")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("CreateUsersWithListInput");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_DeleteUser")]
public async Task<ActionResult<>> _DeleteUser([HttpTrigger(AuthorizationLevel.Anonymous, "Delete", Route = "v2user/{username}")]HttpRequest req, ExecutionContext context, string username)
{
var method = this.GetType().GetMethod("DeleteUser");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_GetUserByName")]
public async Task<ActionResult<User>> _GetUserByName([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2user/{username}")]HttpRequest req, ExecutionContext context, string username)
{
var method = this.GetType().GetMethod("GetUserByName");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<User>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_LoginUser")]
public async Task<ActionResult<string>> _LoginUser([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2user/login")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("LoginUser");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<string>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_LogoutUser")]
public async Task<ActionResult<>> _LogoutUser([HttpTrigger(AuthorizationLevel.Anonymous, "Get", Route = "v2user/logout")]HttpRequest req, ExecutionContext context)
{
var method = this.GetType().GetMethod("LogoutUser");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
[FunctionName("UserApi_UpdateUser")]
public async Task<ActionResult<>> _UpdateUser([HttpTrigger(AuthorizationLevel.Anonymous, "Put", Route = "v2user/{username}")]HttpRequest req, ExecutionContext context, string username)
{
var method = this.GetType().GetMethod("UpdateUser");
if(method == null)
{
return new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
return (await ((Task<>)method.Invoke(this, new object[] { req, context, id })).ConfigureAwait(false));
}
}
}

View File

@ -0,0 +1,147 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// Describes the result of uploading an image resource
/// </summary>
[DataContract]
public partial class ApiResponse : IEquatable<ApiResponse>
{
/// <summary>
/// Gets or Sets Code
/// </summary>
[DataMember(Name="code", EmitDefaultValue=false)]
public int Code { get; set; }
/// <summary>
/// Gets or Sets Type
/// </summary>
[DataMember(Name="type", EmitDefaultValue=false)]
public string Type { get; set; }
/// <summary>
/// Gets or Sets Message
/// </summary>
[DataMember(Name="message", EmitDefaultValue=false)]
public string Message { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class ApiResponse {\n");
sb.Append(" Code: ").Append(Code).Append("\n");
sb.Append(" Type: ").Append(Type).Append("\n");
sb.Append(" Message: ").Append(Message).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((ApiResponse)obj);
}
/// <summary>
/// Returns true if ApiResponse instances are equal
/// </summary>
/// <param name="other">Instance of ApiResponse to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(ApiResponse other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Code == other.Code ||
Code.Equals(other.Code)
) &&
(
Type == other.Type ||
Type != null &&
Type.Equals(other.Type)
) &&
(
Message == other.Message ||
Message != null &&
Message.Equals(other.Message)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
hashCode = hashCode * 59 + Code.GetHashCode();
if (Type != null)
hashCode = hashCode * 59 + Type.GetHashCode();
if (Message != null)
hashCode = hashCode * 59 + Message.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(ApiResponse left, ApiResponse right)
{
return Equals(left, right);
}
public static bool operator !=(ApiResponse left, ApiResponse right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@ -0,0 +1,134 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// A category for a pet
/// </summary>
[DataContract]
public partial class Category : IEquatable<Category>
{
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[RegularExpression("^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")]
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Category {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((Category)obj);
}
/// <summary>
/// Returns true if Category instances are equal
/// </summary>
/// <param name="other">Instance of Category to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(Category other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Id == other.Id ||
Id.Equals(other.Id)
) &&
(
Name == other.Name ||
Name != null &&
Name.Equals(other.Name)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Name != null)
hashCode = hashCode * 59 + Name.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(Category left, Category right)
{
return Equals(left, right);
}
public static bool operator !=(Category left, Category right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@ -0,0 +1,219 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// An order for a pets from the pet store
/// </summary>
[DataContract]
public partial class Order : IEquatable<Order>
{
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
[DataMember(Name="petId", EmitDefaultValue=false)]
public long PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
[DataMember(Name="quantity", EmitDefaultValue=false)]
public int Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
[DataMember(Name="shipDate", EmitDefaultValue=false)]
public DateTime ShipDate { get; set; }
/// <summary>
/// Order Status
/// </summary>
/// <value>Order Status</value>
[TypeConverter(typeof(CustomEnumConverter<StatusEnum>))]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum StatusEnum
{
/// <summary>
/// Enum PlacedEnum for placed
/// </summary>
[EnumMember(Value = "placed")]
PlacedEnum = 1,
/// <summary>
/// Enum ApprovedEnum for approved
/// </summary>
[EnumMember(Value = "approved")]
ApprovedEnum = 2,
/// <summary>
/// Enum DeliveredEnum for delivered
/// </summary>
[EnumMember(Value = "delivered")]
DeliveredEnum = 3
}
/// <summary>
/// Order Status
/// </summary>
/// <value>Order Status</value>
[DataMember(Name="status", EmitDefaultValue=false)]
public StatusEnum Status { get; set; }
/// <summary>
/// Gets or Sets Complete
/// </summary>
[DataMember(Name="complete", EmitDefaultValue=false)]
public bool Complete { get; set; } = false;
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Order {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" PetId: ").Append(PetId).Append("\n");
sb.Append(" Quantity: ").Append(Quantity).Append("\n");
sb.Append(" ShipDate: ").Append(ShipDate).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Complete: ").Append(Complete).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((Order)obj);
}
/// <summary>
/// Returns true if Order instances are equal
/// </summary>
/// <param name="other">Instance of Order to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(Order other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Id == other.Id ||
Id.Equals(other.Id)
) &&
(
PetId == other.PetId ||
PetId.Equals(other.PetId)
) &&
(
Quantity == other.Quantity ||
Quantity.Equals(other.Quantity)
) &&
(
ShipDate == other.ShipDate ||
ShipDate != null &&
ShipDate.Equals(other.ShipDate)
) &&
(
Status == other.Status ||
Status.Equals(other.Status)
) &&
(
Complete == other.Complete ||
Complete.Equals(other.Complete)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
hashCode = hashCode * 59 + Id.GetHashCode();
hashCode = hashCode * 59 + PetId.GetHashCode();
hashCode = hashCode * 59 + Quantity.GetHashCode();
if (ShipDate != null)
hashCode = hashCode * 59 + ShipDate.GetHashCode();
hashCode = hashCode * 59 + Status.GetHashCode();
hashCode = hashCode * 59 + Complete.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(Order left, Order right)
{
return Equals(left, right);
}
public static bool operator !=(Order left, Order right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@ -0,0 +1,223 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// A pet for sale in the pet store
/// </summary>
[DataContract]
public partial class Pet : IEquatable<Pet>
{
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
[DataMember(Name="category", EmitDefaultValue=false)]
public Category Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[Required]
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
[Required]
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Tags
/// </summary>
[DataMember(Name="tags", EmitDefaultValue=false)]
public List<Tag> Tags { get; set; }
/// <summary>
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
[TypeConverter(typeof(CustomEnumConverter<StatusEnum>))]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum StatusEnum
{
/// <summary>
/// Enum AvailableEnum for available
/// </summary>
[EnumMember(Value = "available")]
AvailableEnum = 1,
/// <summary>
/// Enum PendingEnum for pending
/// </summary>
[EnumMember(Value = "pending")]
PendingEnum = 2,
/// <summary>
/// Enum SoldEnum for sold
/// </summary>
[EnumMember(Value = "sold")]
SoldEnum = 3
}
/// <summary>
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
[DataMember(Name="status", EmitDefaultValue=false)]
public StatusEnum Status { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Pet {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((Pet)obj);
}
/// <summary>
/// Returns true if Pet instances are equal
/// </summary>
/// <param name="other">Instance of Pet to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(Pet other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Id == other.Id ||
Id.Equals(other.Id)
) &&
(
Category == other.Category ||
Category != null &&
Category.Equals(other.Category)
) &&
(
Name == other.Name ||
Name != null &&
Name.Equals(other.Name)
) &&
(
PhotoUrls == other.PhotoUrls ||
PhotoUrls != null &&
other.PhotoUrls != null &&
PhotoUrls.SequenceEqual(other.PhotoUrls)
) &&
(
Tags == other.Tags ||
Tags != null &&
other.Tags != null &&
Tags.SequenceEqual(other.Tags)
) &&
(
Status == other.Status ||
Status.Equals(other.Status)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Category != null)
hashCode = hashCode * 59 + Category.GetHashCode();
if (Name != null)
hashCode = hashCode * 59 + Name.GetHashCode();
if (PhotoUrls != null)
hashCode = hashCode * 59 + PhotoUrls.GetHashCode();
if (Tags != null)
hashCode = hashCode * 59 + Tags.GetHashCode();
hashCode = hashCode * 59 + Status.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(Pet left, Pet right)
{
return Equals(left, right);
}
public static bool operator !=(Pet left, Pet right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@ -0,0 +1,133 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// A tag for a pet
/// </summary>
[DataContract]
public partial class Tag : IEquatable<Tag>
{
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Tag {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((Tag)obj);
}
/// <summary>
/// Returns true if Tag instances are equal
/// </summary>
/// <param name="other">Instance of Tag to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(Tag other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Id == other.Id ||
Id.Equals(other.Id)
) &&
(
Name == other.Name ||
Name != null &&
Name.Equals(other.Name)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Name != null)
hashCode = hashCode * 59 + Name.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(Tag left, Tag right)
{
return Equals(left, right);
}
public static bool operator !=(Tag left, Tag right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@ -0,0 +1,218 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Org.OpenAPITools.Converters;
namespace Org.OpenAPITools.Models
{
/// <summary>
/// A User who is purchasing from the pet store
/// </summary>
[DataContract]
public partial class User : IEquatable<User>
{
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long Id { get; set; }
/// <summary>
/// Gets or Sets Username
/// </summary>
[DataMember(Name="username", EmitDefaultValue=false)]
public string Username { get; set; }
/// <summary>
/// Gets or Sets FirstName
/// </summary>
[DataMember(Name="firstName", EmitDefaultValue=false)]
public string FirstName { get; set; }
/// <summary>
/// Gets or Sets LastName
/// </summary>
[DataMember(Name="lastName", EmitDefaultValue=false)]
public string LastName { get; set; }
/// <summary>
/// Gets or Sets Email
/// </summary>
[DataMember(Name="email", EmitDefaultValue=false)]
public string Email { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
[DataMember(Name="password", EmitDefaultValue=false)]
public string Password { get; set; }
/// <summary>
/// Gets or Sets Phone
/// </summary>
[DataMember(Name="phone", EmitDefaultValue=false)]
public string Phone { get; set; }
/// <summary>
/// User Status
/// </summary>
/// <value>User Status</value>
[DataMember(Name="userStatus", EmitDefaultValue=false)]
public int UserStatus { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class User {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Username: ").Append(Username).Append("\n");
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
sb.Append(" LastName: ").Append(LastName).Append("\n");
sb.Append(" Email: ").Append(Email).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Phone: ").Append(Phone).Append("\n");
sb.Append(" UserStatus: ").Append(UserStatus).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((User)obj);
}
/// <summary>
/// Returns true if User instances are equal
/// </summary>
/// <param name="other">Instance of User to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(User other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Id == other.Id ||
Id.Equals(other.Id)
) &&
(
Username == other.Username ||
Username != null &&
Username.Equals(other.Username)
) &&
(
FirstName == other.FirstName ||
FirstName != null &&
FirstName.Equals(other.FirstName)
) &&
(
LastName == other.LastName ||
LastName != null &&
LastName.Equals(other.LastName)
) &&
(
Email == other.Email ||
Email != null &&
Email.Equals(other.Email)
) &&
(
Password == other.Password ||
Password != null &&
Password.Equals(other.Password)
) &&
(
Phone == other.Phone ||
Phone != null &&
Phone.Equals(other.Phone)
) &&
(
UserStatus == other.UserStatus ||
UserStatus.Equals(other.UserStatus)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
var hashCode = 41;
// Suitable nullity checks etc, of course :)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Username != null)
hashCode = hashCode * 59 + Username.GetHashCode();
if (FirstName != null)
hashCode = hashCode * 59 + FirstName.GetHashCode();
if (LastName != null)
hashCode = hashCode * 59 + LastName.GetHashCode();
if (Email != null)
hashCode = hashCode * 59 + Email.GetHashCode();
if (Password != null)
hashCode = hashCode * 59 + Password.GetHashCode();
if (Phone != null)
hashCode = hashCode * 59 + Phone.GetHashCode();
hashCode = hashCode * 59 + UserStatus.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(User left, User right)
{
return Equals(left, right);
}
public static bool operator !=(User left, User right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Linq;
using System.Text;
namespace Org.OpenAPITools.OpenApi
{
/// <summary>
/// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x
/// </summary>
public static class TypeExtensions
{
/// <summary>
/// Produce a friendly name for the type which is unique.
/// </summary>
/// <param name="type"></param>
/// <param name="fullyQualified"></param>
public static string FriendlyId(this Type type, bool fullyQualified = false)
{
var typeName = fullyQualified
? type.FullNameSansTypeParameters().Replace("+", ".")
: type.Name;
if (type.IsGenericType)
{
var genericArgumentIds = type.GetGenericArguments()
.Select(t => t.FriendlyId(fullyQualified))
.ToArray();
return new StringBuilder(typeName)
.Replace($"`{genericArgumentIds.Count()}", string.Empty)
.Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]")
.ToString();
}
return typeName;
}
/// <summary>
/// Determine the fully qualified type name without type parameters.
/// </summary>
/// <param name="type"></param>
public static string FullNameSansTypeParameters(this Type type)
{
var fullName = type.FullName;
if (string.IsNullOrEmpty(fullName))
fullName = type.Name;
var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal);
return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex);
}
}
}

View File

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>A library generated from a OpenAPI doc</Description>
<Copyright>No Copyright</Copyright>
<Authors>OpenAPI</Authors>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
<Version>1.0.0</Version>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<AssemblyName>Org.OpenAPITools</AssemblyName>
<PackageId>Org.OpenAPITools</PackageId>
<UserSecretsId>ec5e31f0-aa1e-4436-9c99-10f99a6500e4</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi.Core" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="0.7.2-preview" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}

View File

@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}