Fix package reference bug

This commit is contained in:
2025-10-12 13:54:51 +02:00
parent 97aaa715dc
commit 671c1214a8
121 changed files with 6431 additions and 69 deletions

View File

@@ -0,0 +1,12 @@
src/**/Controllers/DefaultApi.cs
# Remove unused classes
src/**/Authentication/ApiAuthentication.cs
src/**/Formatters/InputFormatterStream.cs
src/**/OpenApi/TypeExtensions.cs
src/**/Attributes/ValidateModelStateAttribute.cs

View File

@@ -0,0 +1,9 @@
Example.Common.sln
README.md
build.bat
build.sh
src/Example.Common/.gitignore
src/Example.Common/Converters/CustomEnumConverter.cs
src/Example.Common/Example.Common.csproj
src/Example.Common/Example.Common.nuspec
src/Example.Common/Models/ExampleSchemaDto.cs

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}") = "Example.Common", "src\Example.Common\Example.Common.csproj", "{6FC4CFBD-1A07-4F15-A921-39E4D59FF83F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6FC4CFBD-1A07-4F15-A921-39E4D59FF83F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FC4CFBD-1A07-4F15-A921-39E4D59FF83F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FC4CFBD-1A07-4F15-A921-39E4D59FF83F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FC4CFBD-1A07-4F15-A921-39E4D59FF83F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,43 @@
# Example.Common - ASP.NET Core 6.0 Server
Defines all the schemas used in example API
## Upgrade NuGet Packages
NuGet packages get frequently updated.
To upgrade this solution to the latest version of all NuGet packages, use the dotnet-outdated tool.
Install dotnet-outdated tool:
```
dotnet tool install --global dotnet-outdated-tool
```
Upgrade only to new minor versions of packages
```
dotnet outdated --upgrade --version-lock Major
```
Upgrade to all new versions of packages (more likely to include breaking API changes)
```
dotnet outdated --upgrade
```
## Run
Linux/OS X:
```
sh build.sh
```
Windows:
```
build.bat
```

View File

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

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# Generated by: https://openapi-generator.tech
#
dotnet restore src/Example.Common/ && \
dotnet build src/Example.Common/ && \
echo "Now, run the following to start the project: dotnet run -p src/Example.Common/Example.Common.csproj --launch-profile web"

View File

@@ -0,0 +1,37 @@
inputSpec: /api/generated/example/dotnet-models/example-schemas/openapi/openapi/openapi.yaml
generatorName: aspnetcore
templateDir: /api/templates/7.3.0/aspnetcore/
outputDir: /api/generated/example/dotnet-models/example-schemas
modelNameSuffix: Dto
typeMappings:
file: "IFormFile"
importMappings:
IFormFile: "Microsoft.AspNetCore.Http.IFormFile"
schemaMappings:
IFormFile: "Microsoft.AspNetCore.Http.IFormFile"
additionalProperties:
aspnetCoreVersion: "6.0"
packageName: "Example.Common"
packageVersion: "1.0.0"
generateBody: "false"
classModifier: "abstract"
operationModifier: "abstract"
isLibrary: "true"
buildTarget: "library"
enumNameSuffix: ""
enumValueSuffix: ""
operationResultTask: true
operationIsAsync: true
removeModelPackage: true
packageReferences: [
]
modelNamespaces: [
]

View File

@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@@ -0,0 +1,2 @@
README.md
openapi/openapi.yaml

View File

@@ -0,0 +1,2 @@
# OpenAPI YAML
This is a OpenAPI YAML built by the [openapi-generator](https://github.com/openapitools/openapi-generator) project.

View File

@@ -0,0 +1,28 @@
openapi: 3.0.3
info:
description: Defines all the schemas used in example API
title: Schemas for example
version: 1.0.0
servers:
- url: /
paths:
/fake_path_required_for_model_generation:
get:
responses:
"200":
description: OK
components:
schemas:
ExampleSchema:
properties:
id:
example: b1e0773f-ef0c-43cf-a1df-52d17f4a3017
format: uuid
type: string
name:
nullable: false
type: string
description:
nullable: true
type: string
type: object

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,52 @@
/*
* Schemas for example
*
* Defines all the schemas used in example API
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/
using System;
using System.ComponentModel;
using System.Globalization;
using Newtonsoft.Json;
namespace Example.Common.Converters
{
/// <summary>
/// Custom string to enum converter
/// </summary>
public class CustomEnumConverter<T> : TypeConverter
{
/// <summary>
/// Determine if we can convert a type to an enum
/// </summary>
/// <param name="context"></param>
/// <param name="sourceType"></param>
/// <returns></returns>
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
/// <summary>
/// Convert from a type value to an enum
/// </summary>
/// <param name="context"></param>
/// <param name="culture"></param>
/// <param name="value"></param>
/// <returns></returns>
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 + @"""");
}
}
}

View File

@@ -0,0 +1,26 @@
<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>
<OutputType>Library</OutputType>
<AssemblyName>Example.Common</AssemblyName>
<PackageId>Example.Common</PackageId>
<UserSecretsId>c65ceed4-31e0-4bfd-9255-5a7e2215eb25</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="JsonSubTypes" Version="1.8.0" />
</ItemGroup>
<ItemGroup>
<!--<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />-->
</ItemGroup>
</Project>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>1.0.0</version>
<title>OpenAPI Library</title>
<authors>OpenAPI</authors>
<owners>OpenAPI</owners>
<licenseUrl>http://localhost</licenseUrl>
<!--
<projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
-->
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A library generated from a OpenAPI doc</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>No Copyright</copyright>
<tags>Example.Common</tags>
</metadata>
</package>

View File

@@ -0,0 +1,148 @@
/*
* Schemas for example
*
* Defines all the schemas used in example API
*
* 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 Example.Common.Converters;
namespace Example.Common.Models
{
/// <summary>
///
/// </summary>
[DataContract]
public class ExampleSchemaDto : IEquatable<ExampleSchemaDto>
{
/// <summary>
/// Gets or Sets Id
/// </summary>
/// <example>b1e0773f-ef0c-43cf-a1df-52d17f4a3017</example>
[DataMember(Name="id", EmitDefaultValue=false)]
public Guid Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Gets or Sets Description
/// </summary>
[DataMember(Name="description", EmitDefaultValue=true)]
public string Description { 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 ExampleSchemaDto {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" Description: ").Append(Description).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 JsonConvert.SerializeObject(this, 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((ExampleSchemaDto)obj);
}
/// <summary>
/// Returns true if ExampleSchemaDto instances are equal
/// </summary>
/// <param name="other">Instance of ExampleSchemaDto to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(ExampleSchemaDto other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
(
Id == other.Id ||
Id != null &&
Id.Equals(other.Id)
) &&
(
Name == other.Name ||
Name != null &&
Name.Equals(other.Name)
) &&
(
Description == other.Description ||
Description != null &&
Description.Equals(other.Description)
);
}
/// <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 :)
if (Id != null)
hashCode = hashCode * 59 + Id.GetHashCode();
if (Name != null)
hashCode = hashCode * 59 + Name.GetHashCode();
if (Description != null)
hashCode = hashCode * 59 + Description.GetHashCode();
return hashCode;
}
}
#region Operators
#pragma warning disable 1591
public static bool operator ==(ExampleSchemaDto left, ExampleSchemaDto right)
{
return Equals(left, right);
}
public static bool operator !=(ExampleSchemaDto left, ExampleSchemaDto right)
{
return !Equals(left, right);
}
#pragma warning restore 1591
#endregion Operators
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="LocalFeed" value="/api/generated/localFeed/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>