From b7190d9f64a73f5054c8e2cae984758d4dcba11c Mon Sep 17 00:00:00 2001
From: Paulo Morgado <470455+paulomorgado@users.noreply.github.com>
Date: Fri, 8 Dec 2023 09:13:38 +0000
Subject: [PATCH] Add NSwag specific metadata to OpenApiReference
OpenApiProjectReference items and use it to build the command line. (#4565)
* Add NSwag specific metadata to OpenApiReference OpenApiProjectReference items and use it to build the command line.
* Added support to for client and client interface supression.
---
.../NSwag.ApiDescription.Client.props | 170 ++++++++++++
.../NSwag.ApiDescription.Client.targets | 257 +++++++++++++++++-
src/NSwag.sln | 1 +
3 files changed, 426 insertions(+), 2 deletions(-)
diff --git a/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.props b/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.props
index 9d235ee141..4f970e795c 100644
--- a/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.props
+++ b/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.props
@@ -4,9 +4,179 @@
NSwagCSharp
+ $(NSwagClientBaseClass)
+ $(NSwagConfigurationClass)
+ $(NSwagGenerateClientClasses)
+ $(NSwagSuppressClientClassesOutput)
+ $(NSwagGenerateClientInterfaces)
+ $(NSwagSuppressClientInterfacesOutput)
+ $(NSwagClientBaseInterface)
+ $(NSwagInjectHttpClient)
+ $(NSwagDisposeHttpClient)
+ $(NSwagProtectedMethods)
+ $(NSwagGenerateExceptionClasses)
+ $(NSwagExceptionClass)
+ $(NSwagWrapDtoExceptions)
+ $(NSwagUseHttpClientCreationMethod)
+ $(NSwagHttpClientType)
+ $(NSwagUseHttpRequestMessageCreationMethod)
+ $(NSwagUseBaseUrl)
+ $(NSwagGenerateBaseUrlProperty)
+ $(NSwagGenerateSyncMethods)
+ $(NSwagGeneratePrepareRequestAndProcessResponseAsAsyncMethods)
+ $(NSwagExposeJsonSerializerSettings)
+ $(NSwagClientClassAccessModifier)
+ $(NSwagTypeAccessModifier)
+ $(NSwagGenerateContractsOutput)
+ $(NSwagContractsNamespace)
+ $(NSwagContractsOutputFilePath)
+ $(NSwagParameterDateTimeFormat)
+ $(NSwagParameterDateFormat)
+ $(NSwagGenerateUpdateJsonSerializerSettingsMethod)
+ $(NSwagUseRequestAndResponseSerializationSettings)
+ $(NSwagSerializeTypeInformation)
+ $(NSwagQueryNullValue)
+ $(NSwagOperationGenerationMode)
+ $(NSwagAdditionalNamespaceUsages)
+ $(NSwagAdditionalContractNamespaceUsages)
+ $(NSwagGenerateOptionalParameters)
+ $(NSwagGenerateJsonMethods)
+ $(NSwagEnforceFlagEnums)
+ $(NSwagParameterArrayType)
+ $(NSwagParameterDictionaryType)
+ $(NSwagResponseArrayType)
+ $(NSwagResponseDictionaryType)
+ $(NSwagWrapResponses)
+ $(NSwagWrapResponseMethods)
+ $(NSwagGenerateResponseClasses)
+ $(NSwagResponseClass)
+ $(NSwagNamespace)
+ $(NSwagRequiredPropertiesMustBeDefined)
+ $(NSwagDateType)
+ $(NSwagJsonConverters)
+ $(NSwagAnyType)
+ $(NSwagDateTimeType)
+ $(NSwagTimeType)
+ $(NSwagTimeSpanType)
+ $(NSwagArrayType)
+ $(NSwagArrayInstanceType)
+ $(NSwagDictionaryType)
+ $(NSwagDictionaryInstanceType)
+ $(NSwagArrayBaseType)
+ $(NSwagDictionaryBaseType)
+ $(NSwagClassStyle)
+ $(NSwagJsonLibrary)
+ $(NSwagGenerateDefaultValues)
+ $(NSwagGenerateDataAnnotations)
+ $(NSwagExcludedTypeNames)
+ $(NSwagExcludedParameterNames)
+ $(NSwagHandleReferences)
+ $(NSwagGenerateImmutableArrayProperties)
+ $(NSwagGenerateImmutableDictionaryProperties)
+ $(NSwagJsonSerializerSettingsTransformationMethod)
+ $(NSwagInlineNamedArrays)
+ $(NSwagInlineNamedDictionaries)
+ $(NSwagInlineNamedTuples)
+ $(NSwagInlineNamedAny)
+ $(NSwagGenerateDtoTypes)
+ $(NSwagGenerateOptionalPropertiesAsNullable)
+ $(NSwagGenerateNullableReferenceTypes)
+ $(NSwagTemplateDirectory)
+ $(NSwagTypeNameGeneratorType)
+ $(NSwagPropertyNameGeneratorType)
+ $(NSwagEnumNameGeneratorType)
+ $(NSwagServiceHost)
+ $(NSwagServiceSchemes)
+ $(NSwagOutput)
+ $(NSwagNewLineBehavior)
NSwagCSharp
+ $(NSwagClientBaseClass)
+ $(NSwagConfigurationClass)
+ $(NSwagGenerateClientClasses)
+ $(NSwagSuppressClientClassesOutput)
+ $(NSwagGenerateClientInterfaces)
+ $(NSwagSuppressClientInterfacesOutput)
+ $(NSwagClientBaseInterface)
+ $(NSwagInjectHttpClient)
+ $(NSwagDisposeHttpClient)
+ $(NSwagProtectedMethods)
+ $(NSwagGenerateExceptionClasses)
+ $(NSwagExceptionClass)
+ $(NSwagWrapDtoExceptions)
+ $(NSwagUseHttpClientCreationMethod)
+ $(NSwagHttpClientType)
+ $(NSwagUseHttpRequestMessageCreationMethod)
+ $(NSwagUseBaseUrl)
+ $(NSwagGenerateBaseUrlProperty)
+ $(NSwagGenerateSyncMethods)
+ $(NSwagGeneratePrepareRequestAndProcessResponseAsAsyncMethods)
+ $(NSwagExposeJsonSerializerSettings)
+ $(NSwagClientClassAccessModifier)
+ $(NSwagTypeAccessModifier)
+ $(NSwagGenerateContractsOutput)
+ $(NSwagContractsNamespace)
+ $(NSwagContractsOutputFilePath)
+ $(NSwagParameterDateTimeFormat)
+ $(NSwagParameterDateFormat)
+ $(NSwagGenerateUpdateJsonSerializerSettingsMethod)
+ $(NSwagUseRequestAndResponseSerializationSettings)
+ $(NSwagSerializeTypeInformation)
+ $(NSwagQueryNullValue)
+ $(NSwagOperationGenerationMode)
+ $(NSwagAdditionalNamespaceUsages)
+ $(NSwagAdditionalContractNamespaceUsages)
+ $(NSwagGenerateOptionalParameters)
+ $(NSwagGenerateJsonMethods)
+ $(NSwagEnforceFlagEnums)
+ $(NSwagParameterArrayType)
+ $(NSwagParameterDictionaryType)
+ $(NSwagResponseArrayType)
+ $(NSwagResponseDictionaryType)
+ $(NSwagWrapResponses)
+ $(NSwagWrapResponseMethods)
+ $(NSwagGenerateResponseClasses)
+ $(NSwagResponseClass)
+ $(NSwagNamespace)
+ $(NSwagRequiredPropertiesMustBeDefined)
+ $(NSwagDateType)
+ $(NSwagJsonConverters)
+ $(NSwagAnyType)
+ $(NSwagDateTimeType)
+ $(NSwagTimeType)
+ $(NSwagTimeSpanType)
+ $(NSwagArrayType)
+ $(NSwagArrayInstanceType)
+ $(NSwagDictionaryType)
+ $(NSwagDictionaryInstanceType)
+ $(NSwagArrayBaseType)
+ $(NSwagDictionaryBaseType)
+ $(NSwagClassStyle)
+ $(NSwagJsonLibrary)
+ $(NSwagGenerateDefaultValues)
+ $(NSwagGenerateDataAnnotations)
+ $(NSwagExcludedTypeNames)
+ $(NSwagExcludedParameterNames)
+ $(NSwagHandleReferences)
+ $(NSwagGenerateImmutableArrayProperties)
+ $(NSwagGenerateImmutableDictionaryProperties)
+ $(NSwagJsonSerializerSettingsTransformationMethod)
+ $(NSwagInlineNamedArrays)
+ $(NSwagInlineNamedDictionaries)
+ $(NSwagInlineNamedTuples)
+ $(NSwagInlineNamedAny)
+ $(NSwagGenerateDtoTypes)
+ $(NSwagGenerateOptionalPropertiesAsNullable)
+ $(NSwagGenerateNullableReferenceTypes)
+ $(NSwagTemplateDirectory)
+ $(NSwagTypeNameGeneratorType)
+ $(NSwagPropertyNameGeneratorType)
+ $(NSwagEnumNameGeneratorType)
+ $(NSwagServiceHost)
+ $(NSwagServiceSchemes)
+ $(NSwagOutput)
+ $(NSwagNewLineBehavior)
diff --git a/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets b/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets
index a3758b0bfa..cf317863bd 100644
--- a/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets
+++ b/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets
@@ -19,12 +19,265 @@
$(_NSwagCommand) openapi2csclient /className:%(ClassName) /namespace:%(Namespace)
- %(Command) /GenerateExceptionClasses:false
+ %(Command) /GenerateExceptionClasses:false
%(Command) /input:"%(FullPath)" /output:"%(OutputPath)" %(Options)
-
+
+ %(Command) /clientBaseClass:%(NSwagClientBaseClass)
+
+
+ %(Command) /configurationClass:%(NSwagConfigurationClass)
+
+
+ %(Command) /generateClientClasses:%(NSwagGenerateClientClasses)
+
+
+ %(Command) /suppressClientClassesOutput:%(NSwagSuppressClientClassesOutput)
+
+
+ %(Command) /generateClientInterfaces:%(NSwagGenerateClientInterfaces)
+
+
+ %(Command) /suppressClientInterfacesOutput:%(NSwagSuppressClientInterfacesOutput)
+
+
+ %(Command) /clientBaseInterface:%(NSwagClientBaseInterface)
+
+
+ %(Command) /injectHttpClient:%(NSwagInjectHttpClient)
+
+
+ %(Command) /disposeHttpClient:%(NSwagDisposeHttpClient)
+
+
+ %(Command) /protectedMethods:%(NSwagProtectedMethods)
+
+
+ %(Command) /exceptionClass:%(NSwagExceptionClass)
+
+
+ %(Command) /wrapDtoExceptions:%(NSwagWrapDtoExceptions)
+
+
+ %(Command) /useHttpClientCreationMethod:%(NSwagUseHttpClientCreationMethod)
+
+
+ %(Command) /httpClientType:%(NSwagHttpClientType)
+
+
+ %(Command) /useHttpRequestMessageCreationMethod:%(NSwagUseHttpRequestMessageCreationMethod)
+
+
+ %(Command) /useBaseUrl:%(NSwagUseBaseUrl)
+
+
+ %(Command) /generateBaseUrlProperty:%(NSwagGenerateBaseUrlProperty)
+
+
+ %(Command) /generateSyncMethods:%(NSwagGenerateSyncMethods)
+
+
+ %(Command) /generatePrepareRequestAndProcessResponseAsAsyncMethods:%(NSwagGeneratePrepareRequestAndProcessResponseAsAsyncMethods)
+
+
+ %(Command) /exposeJsonSerializerSettings:%(NSwagExposeJsonSerializerSettings)
+
+
+ %(Command) /clientClassAccessModifier:%(NSwagClientClassAccessModifier)
+
+
+ %(Command) /typeAccessModifier:%(NSwagTypeAccessModifier)
+
+
+ %(Command) /generateContractsOutput:%(NSwagGenerateContractsOutput)
+
+
+ %(Command) /contractsNamespace:%(NSwagContractsNamespace)
+
+
+ %(Command) /contractsOutputFilePath:%(NSwagContractsOutputFilePath)
+
+
+ %(Command) /parameterDateTimeFormat:%(NSwagParameterDateTimeFormat)
+
+
+ %(Command) /parameterDateFormat:%(NSwagParameterDateFormat)
+
+
+ %(Command) /generateUpdateJsonSerializerSettingsMethod:%(NSwagGenerateUpdateJsonSerializerSettingsMethod)
+
+
+ %(Command) /useRequestAndResponseSerializationSettings:%(NSwagUseRequestAndResponseSerializationSettings)
+
+
+ %(Command) /serializeTypeInformation:%(NSwagSerializeTypeInformation)
+
+
+ %(Command) /queryNullValue:%(NSwagQueryNullValue)
+
+
+ %(Command) /operationGenerationMode:%(NSwagOperationGenerationMode)
+
+
+ %(Command) /additionalNamespaceUsages:%(NSwagAdditionalNamespaceUsages)
+
+
+ %(Command) /additionalContractNamespaceUsages:%(NSwagAdditionalContractNamespaceUsages)
+
+
+ %(Command) /generateOptionalParameters:%(NSwagGenerateOptionalParameters)
+
+
+ %(Command) /generateJsonMethods:%(NSwagGenerateJsonMethods)
+
+
+ %(Command) /enforceFlagEnums:%(NSwagEnforceFlagEnums)
+
+
+ %(Command) /parameterArrayType:%(NSwagParameterArrayType)
+
+
+ %(Command) /parameterDictionaryType:%(NSwagParameterDictionaryType)
+
+
+ %(Command) /responseArrayType:%(NSwagResponseArrayType)
+
+
+ %(Command) /responseDictionaryType:%(NSwagResponseDictionaryType)
+
+
+ %(Command) /wrapResponses:%(NSwagWrapResponses)
+
+
+ %(Command) /wrapResponseMethods:%(NSwagWrapResponseMethods)
+
+
+ %(Command) /generateResponseClasses:%(NSwagGenerateResponseClasses)
+
+
+ %(Command) /responseClass:%(NSwagResponseClass)
+
+
+ %(Command) /namespace:%(NSwagNamespace)
+
+
+ %(Command) /requiredPropertiesMustBeDefined:%(NSwagRequiredPropertiesMustBeDefined)
+
+
+ %(Command) /dateType:%(NSwagDateType)
+
+
+ %(Command) /jsonConverters:%(NSwagJsonConverters)
+
+
+ %(Command) /anyType:%(NSwagAnyType)
+
+
+ %(Command) /dateTimeType:%(NSwagDateTimeType)
+
+
+ %(Command) /timeType:%(NSwagTimeType)
+
+
+ %(Command) /timeSpanType:%(NSwagTimeSpanType)
+
+
+ %(Command) /arrayType:%(NSwagArrayType)
+
+
+ %(Command) /arrayInstanceType:%(NSwagArrayInstanceType)
+
+
+ %(Command) /dictionaryType:%(NSwagDictionaryType)
+
+
+ %(Command) /dictionaryInstanceType:%(NSwagDictionaryInstanceType)
+
+
+ %(Command) /arrayBaseType:%(NSwagArrayBaseType)
+
+
+ %(Command) /dictionaryBaseType:%(NSwagDictionaryBaseType)
+
+
+ %(Command) /classStyle:%(NSwagClassStyle)
+
+
+ %(Command) /jsonLibrary:%(NSwagJsonLibrary)
+
+
+ %(Command) /generateDefaultValues:%(NSwagGenerateDefaultValues)
+
+
+ %(Command) /generateDataAnnotations:%(NSwagGenerateDataAnnotations)
+
+
+ %(Command) /excludedTypeNames:%(NSwagExcludedTypeNames)
+
+
+ %(Command) /excludedParameterNames:%(NSwagExcludedParameterNames)
+
+
+ %(Command) /handleReferences:%(NSwagHandleReferences)
+
+
+ %(Command) /generateImmutableArrayProperties:%(NSwagGenerateImmutableArrayProperties)
+
+
+ %(Command) /generateImmutableDictionaryProperties:%(NSwagGenerateImmutableDictionaryProperties)
+
+
+ %(Command) /jsonSerializerSettingsTransformationMethod:%(NSwagJsonSerializerSettingsTransformationMethod)
+
+
+ %(Command) /inlineNamedArrays:%(NSwagInlineNamedArrays)
+
+
+ %(Command) /inlineNamedDictionaries:%(NSwagInlineNamedDictionaries)
+
+
+ %(Command) /inlineNamedTuples:%(NSwagInlineNamedTuples)
+
+
+ %(Command) /inlineNamedAny:%(NSwagInlineNamedAny)
+
+
+ %(Command) /generateDtoTypes:%(NSwagGenerateDtoTypes)
+
+
+ %(Command) /generateOptionalPropertiesAsNullable:%(NSwagGenerateOptionalPropertiesAsNullable)
+
+
+ %(Command) /generateNullableReferenceTypes:%(NSwagGenerateNullableReferenceTypes)
+
+
+ %(Command) /templateDirectory:%(NSwagTemplateDirectory)
+
+
+ %(Command) /typeNameGeneratorType:%(NSwagTypeNameGeneratorType)
+
+
+ %(Command) /propertyNameGeneratorType:%(NSwagPropertyNameGeneratorType)
+
+
+ %(Command) /enumNameGeneratorType:%(NSwagEnumNameGeneratorType)
+
+
+ %(Command) /serviceHost:%(NSwagServiceHost)
+
+
+ %(Command) /serviceSchemes:%(NSwagServiceSchemes)
+
+
+ %(Command) /output:%(NSwagOutput)
+
+
+ %(Command) /newLineBehavior:%(NSwagNewLineBehavior)
+
+
+
diff --git a/src/NSwag.sln b/src/NSwag.sln
index cb20432861..3b9ba67007 100644
--- a/src/NSwag.sln
+++ b/src/NSwag.sln
@@ -102,6 +102,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NSwag.ApiDescription.Client", "NSwag.ApiDescription.Client", "{E6E40935-0C79-480B-BF29-8C493AC7E518}"
ProjectSection(SolutionItems) = preProject
NSwag.ApiDescription.Client\NSwag.ApiDescription.Client.nuspec = NSwag.ApiDescription.Client\NSwag.ApiDescription.Client.nuspec
+ NSwag.ApiDescription.Client\NSwag.ApiDescription.Client.props = NSwag.ApiDescription.Client\NSwag.ApiDescription.Client.props
NSwag.ApiDescription.Client\NSwag.ApiDescription.Client.targets = NSwag.ApiDescription.Client\NSwag.ApiDescription.Client.targets
EndProjectSection
EndProject