diff --git a/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj b/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj
index a76c04e40b..6f901cc5fe 100644
--- a/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj
+++ b/src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj
index 6bf0b0c1cc..7c38c5746d 100644
--- a/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj
+++ b/src/NSwag.CodeGeneration.CSharp/NSwag.CodeGeneration.CSharp.csproj
@@ -16,6 +16,6 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj
index ba44abcbf1..a447edbdfa 100644
--- a/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj
+++ b/src/NSwag.CodeGeneration.Tests/NSwag.CodeGeneration.Tests.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj b/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj
index 1c458ccc51..c6f54a59ce 100644
--- a/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj
+++ b/src/NSwag.CodeGeneration.TypeScript/NSwag.CodeGeneration.TypeScript.csproj
@@ -16,6 +16,6 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
index 07d420f5f8..478ddb7200 100644
--- a/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
+++ b/src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj b/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj
index dd2f11383b..61b64948be 100644
--- a/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj
+++ b/src/NSwag.Core.Yaml/NSwag.Core.Yaml.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/src/NSwag.Core/NSwag.Core.csproj b/src/NSwag.Core/NSwag.Core.csproj
index 68d7e8b7d9..7eff0331c6 100644
--- a/src/NSwag.Core/NSwag.Core.csproj
+++ b/src/NSwag.Core/NSwag.Core.csproj
@@ -9,6 +9,6 @@
-
+
\ No newline at end of file
diff --git a/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs b/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs
index 1c6a1b6014..7cf08d1806 100644
--- a/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs
+++ b/src/NSwag.Generation.AspNetCore/Processors/OperationParameterProcessor.cs
@@ -445,7 +445,7 @@ private OpenApiParameter CreatePrimitiveParameter(
bool enforceNotNull = false)
{
var contextualParameterType =
- extendedApiParameter.ParameterInfo?.ToContextualParameter() as ContextualType ??
+ extendedApiParameter.ParameterInfo?.ToContextualParameter()?.ParameterType ??
extendedApiParameter.PropertyInfo?.ToContextualProperty()?.PropertyType ??
extendedApiParameter.ParameterType.ToContextualType(extendedApiParameter.Attributes);
diff --git a/src/NSwag.Generation.Tests/OpenApiDocumentGeneratorTests.cs b/src/NSwag.Generation.Tests/OpenApiDocumentGeneratorTests.cs
index 628d864f6c..022384d349 100644
--- a/src/NSwag.Generation.Tests/OpenApiDocumentGeneratorTests.cs
+++ b/src/NSwag.Generation.Tests/OpenApiDocumentGeneratorTests.cs
@@ -9,7 +9,6 @@ namespace NSwag.Generation.Tests
{
public class OpenApiDocumentGeneratorTests
{
-
public class TestController
{
public void HasArrayParameter(string[] foo)
@@ -34,7 +33,7 @@ private OpenApiParameter GetParameter(SchemaType schemaType)
.Methods
.Single(m => m.Name == "HasArrayParameter");
- return generator.CreatePrimitiveParameter("foo", "bar", methodInfo.Parameters.First());
+ return generator.CreatePrimitiveParameter("foo", "bar", methodInfo.Parameters.First().ParameterType);
}
[Fact]
diff --git a/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs b/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs
index 03a0c5e642..cdd877c54a 100644
--- a/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs
+++ b/src/NSwag.Generation.WebApi/Processors/OperationParameterProcessor.cs
@@ -43,20 +43,20 @@ public bool Process(OperationProcessorContext context)
var position = 1;
foreach (var contextualParameter in parameters.Select(p => p.ToContextualParameter())
- .Where(p => p.Type != typeof(CancellationToken) &&
- !p.ContextAttributes.GetAssignableToTypeName("SwaggerIgnoreAttribute", TypeNameStyle.Name).Any() &&
- !p.ContextAttributes.GetAssignableToTypeName("FromServicesAttribute", TypeNameStyle.Name).Any() &&
- !p.ContextAttributes.GetAssignableToTypeName("BindNeverAttribute", TypeNameStyle.Name).Any()))
+ .Where(p => p.ParameterType.Type != typeof(CancellationToken) &&
+ !p.GetAttributes(true).GetAssignableToTypeName("SwaggerIgnoreAttribute", TypeNameStyle.Name).Any() &&
+ !p.GetAttributes(true).GetAssignableToTypeName("FromServicesAttribute", TypeNameStyle.Name).Any() &&
+ !p.GetAttributes(true).GetAssignableToTypeName("BindNeverAttribute", TypeNameStyle.Name).Any()))
{
var parameterName = contextualParameter.Name;
- dynamic fromRouteAttribute = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("Microsoft.AspNetCore.Mvc.FromRouteAttribute");
- dynamic fromHeaderAttribute = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("Microsoft.AspNetCore.Mvc.FromHeaderAttribute");
- dynamic fromFormAttribute = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("Microsoft.AspNetCore.Mvc.FromFormAttribute");
+ dynamic fromRouteAttribute = contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("Microsoft.AspNetCore.Mvc.FromRouteAttribute");
+ dynamic fromHeaderAttribute = contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("Microsoft.AspNetCore.Mvc.FromHeaderAttribute");
+ dynamic fromFormAttribute = contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("Microsoft.AspNetCore.Mvc.FromFormAttribute");
- var fromBodyAttribute = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("FromBodyAttribute", TypeNameStyle.Name);
- var fromUriAttribute = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("FromUriAttribute", TypeNameStyle.Name) ??
- contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("FromQueryAttribute", TypeNameStyle.Name);
+ var fromBodyAttribute = contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("FromBodyAttribute", TypeNameStyle.Name);
+ var fromUriAttribute = contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("FromUriAttribute", TypeNameStyle.Name) ??
+ contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("FromQueryAttribute", TypeNameStyle.Name);
string bodyParameterName = fromBodyAttribute.TryGetPropertyValue("Name") ?? parameterName;
string uriParameterName = fromUriAttribute.TryGetPropertyValue("Name") ?? parameterName;
@@ -81,7 +81,7 @@ public bool Process(OperationProcessorContext context)
}
else
{
- var parameterInfo = _settings.SchemaSettings.ReflectionService.GetDescription(contextualParameter, _settings.SchemaSettings);
+ var parameterInfo = _settings.SchemaSettings.ReflectionService.GetDescription(contextualParameter.ParameterType, _settings.SchemaSettings);
operationParameter = TryAddFileParameter(context, parameterInfo, contextualParameter);
if (operationParameter == null)
@@ -118,7 +118,7 @@ public bool Process(OperationProcessorContext context)
if (parameterInfo.IsComplexType)
{
// Check for a custom ParameterBindingAttribute (OWIN/WebAPI only)
- var parameterBindingAttribute = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("ParameterBindingAttribute", TypeNameStyle.Name);
+ var parameterBindingAttribute = contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("ParameterBindingAttribute", TypeNameStyle.Name);
if (parameterBindingAttribute != null && fromBodyAttribute == null && fromUriAttribute == null && !_settings.IsAspNetCore)
{
// If binding attribute is defined in GET method context, it cannot be body parameter and path and form attributes were checked earlier
@@ -129,7 +129,7 @@ public bool Process(OperationProcessorContext context)
else
{
// Try to find a [WillReadBody] attribute on either the action parameter or the bindingAttribute's class
- var willReadBodyAttribute = contextualParameter.ContextAttributes.Concat(parameterBindingAttribute.GetType().GetTypeInfo().GetCustomAttributes())
+ var willReadBodyAttribute = contextualParameter.GetAttributes(true).Concat(parameterBindingAttribute.GetType().GetTypeInfo().GetCustomAttributes())
.FirstAssignableToTypeNameOrDefault("WillReadBodyAttribute", TypeNameStyle.Name);
if (willReadBodyAttribute == null)
@@ -302,8 +302,8 @@ private void RemoveUnusedPathParameters(OpenApiOperationDescription operationDes
private OpenApiParameter TryAddFileParameter(
OperationProcessorContext context, JsonTypeDescription typeInfo, ContextualParameterInfo contextualParameter)
{
- var isFileArray = IsFileArray(contextualParameter.Type, typeInfo);
- var hasSwaggerFileAttribute = contextualParameter.Attributes
+ var isFileArray = IsFileArray(contextualParameter.ParameterType.Type, typeInfo);
+ var hasSwaggerFileAttribute = contextualParameter.GetAttributes(true)
.FirstAssignableToTypeNameOrDefault("SwaggerFileAttribute", TypeNameStyle.Name) != null;
if (typeInfo.Type == JsonObjectType.File ||
@@ -322,7 +322,7 @@ private OpenApiParameter AddFileParameter(OperationProcessorContext context, Con
// TODO: Check if there is a way to control the property name
var parameterDocumentation = contextualParameter.GetDescription(_settings.SchemaSettings);
var operationParameter = context.DocumentGenerator.CreatePrimitiveParameter(
- contextualParameter.Name, parameterDocumentation, contextualParameter);
+ contextualParameter.Name, parameterDocumentation, contextualParameter.ParameterType);
InitializeFileParameter(operationParameter, isFileArray);
context.OperationDescription.Operation.Parameters.Add(operationParameter);
@@ -354,12 +354,12 @@ private OpenApiParameter AddBodyParameter(OperationProcessorContext context, str
{
OpenApiParameter operationParameter;
- var typeDescription = _settings.SchemaSettings.ReflectionService.GetDescription(contextualParameter, _settings.SchemaSettings);
- var isRequired = _settings.AllowNullableBodyParameters == false || contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("RequiredAttribute", TypeNameStyle.Name) != null;
+ var typeDescription = _settings.SchemaSettings.ReflectionService.GetDescription(contextualParameter.ParameterType, _settings.SchemaSettings);
+ var isRequired = _settings.AllowNullableBodyParameters == false || contextualParameter.GetAttributes(true).FirstAssignableToTypeNameOrDefault("RequiredAttribute", TypeNameStyle.Name) != null;
var isNullable = _settings.AllowNullableBodyParameters && (typeDescription.IsNullable && !isRequired);
var operation = context.OperationDescription.Operation;
- if (contextualParameter.TypeName == "XmlDocument" || contextualParameter.Type.InheritsFromTypeName("XmlDocument", TypeNameStyle.Name))
+ if (contextualParameter.ParameterType.Name == "XmlDocument" || contextualParameter.ParameterType.Type.InheritsFromTypeName("XmlDocument", TypeNameStyle.Name))
{
operation.TryAddConsumes("application/xml");
operationParameter = new OpenApiParameter
@@ -377,7 +377,7 @@ private OpenApiParameter AddBodyParameter(OperationProcessorContext context, str
};
operation.Parameters.Add(operationParameter);
}
- else if (contextualParameter.Type.IsAssignableToTypeName("System.IO.Stream", TypeNameStyle.FullName))
+ else if (contextualParameter.ParameterType.Type.IsAssignableToTypeName("System.IO.Stream", TypeNameStyle.FullName))
{
operation.TryAddConsumes("application/octet-stream");
operationParameter = new OpenApiParameter
@@ -406,7 +406,7 @@ private OpenApiParameter AddBodyParameter(OperationProcessorContext context, str
IsNullableRaw = isNullable,
Description = contextualParameter.GetDescription(_settings.SchemaSettings),
Schema = context.SchemaGenerator.GenerateWithReferenceAndNullability(
- contextualParameter, isNullable, schemaResolver: context.SchemaResolver)
+ contextualParameter.ParameterType, isNullable, schemaResolver: context.SchemaResolver)
};
operation.Parameters.Add(operationParameter);
}
@@ -423,7 +423,7 @@ private OpenApiParameter AddPrimitiveParametersFromUri(
{
var parameterDocumentation = contextualParameter.GetDescription(_settings.SchemaSettings);
var operationParameter = context.DocumentGenerator.CreatePrimitiveParameter(
- name, parameterDocumentation, contextualParameter);
+ name, parameterDocumentation, contextualParameter.ParameterType);
operationParameter.Kind = OpenApiParameterKind.Query;
operation.Parameters.Add(operationParameter);
@@ -431,23 +431,23 @@ private OpenApiParameter AddPrimitiveParametersFromUri(
}
else
{
- foreach (var contextualProperty in contextualParameter.Type.GetContextualProperties())
+ foreach (var contextualProperty in contextualParameter.ParameterType.Type.GetContextualProperties())
{
- if (contextualProperty.ContextAttributes.Select(a => a.GetType()).All(a =>
+ if (contextualProperty.GetAttributes(true).Select(a => a.GetType()).All(a =>
!a.IsAssignableToTypeName("SwaggerIgnoreAttribute", TypeNameStyle.Name) &&
!a.IsAssignableToTypeName("JsonIgnoreAttribute", TypeNameStyle.Name)))
{
- var fromQueryAttribute = contextualProperty.ContextAttributes.SingleOrDefault(a => a.GetType().Name == "FromQueryAttribute");
+ var fromQueryAttribute = contextualProperty.GetAttributes(true).SingleOrDefault(a => a.GetType().Name == "FromQueryAttribute");
var propertyName = fromQueryAttribute.TryGetPropertyValue("Name") ??
_settings.SchemaSettings.ReflectionService.GetPropertyName(contextualProperty, _settings.SchemaSettings);
- dynamic fromRouteAttribute = contextualProperty.ContextAttributes.SingleOrDefault(a => a.GetType().FullName == "Microsoft.AspNetCore.Mvc.FromRouteAttribute");
+ dynamic fromRouteAttribute = contextualProperty.GetAttributes(true).SingleOrDefault(a => a.GetType().FullName == "Microsoft.AspNetCore.Mvc.FromRouteAttribute");
if (fromRouteAttribute != null && !string.IsNullOrEmpty(fromRouteAttribute?.Name))
{
propertyName = fromRouteAttribute?.Name;
}
- dynamic fromHeaderAttribute = contextualProperty.ContextAttributes.SingleOrDefault(a => a.GetType().FullName == "Microsoft.AspNetCore.Mvc.FromHeaderAttribute");
+ dynamic fromHeaderAttribute = contextualProperty.GetAttributes(true).SingleOrDefault(a => a.GetType().FullName == "Microsoft.AspNetCore.Mvc.FromHeaderAttribute");
if (fromHeaderAttribute != null && !string.IsNullOrEmpty(fromHeaderAttribute?.Name))
{
propertyName = fromHeaderAttribute?.Name;
@@ -500,7 +500,7 @@ private OpenApiParameter AddPrimitiveParameter(
if (contextualParameter.ParameterInfo.HasDefaultValue)
{
var defaultValue = context.SchemaGenerator.ConvertDefaultValue(
- contextualParameter, contextualParameter.ParameterInfo.DefaultValue);
+ contextualParameter.ParameterType, contextualParameter.ParameterInfo.DefaultValue);
if (_settings.SchemaSettings.SchemaType == SchemaType.Swagger2)
{
diff --git a/src/NSwag.Generation/NSwag.Generation.csproj b/src/NSwag.Generation/NSwag.Generation.csproj
index 79a5076b69..ab5c6cd085 100644
--- a/src/NSwag.Generation/NSwag.Generation.csproj
+++ b/src/NSwag.Generation/NSwag.Generation.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/NSwag.Generation/OpenApiDocumentGenerator.cs b/src/NSwag.Generation/OpenApiDocumentGenerator.cs
index ae7f7f9fcb..47ea6bf17d 100644
--- a/src/NSwag.Generation/OpenApiDocumentGenerator.cs
+++ b/src/NSwag.Generation/OpenApiDocumentGenerator.cs
@@ -79,7 +79,7 @@ public OpenApiParameter CreateUntypedPathParameter(string parameterName, string
public OpenApiParameter CreatePrimitiveParameter(string name, ContextualParameterInfo contextualParameter)
{
var documentation = contextualParameter.GetDescription(_settings.SchemaSettings);
- return CreatePrimitiveParameter(name, documentation, contextualParameter);
+ return CreatePrimitiveParameter(name, documentation, contextualParameter.ParameterType);
}
/// Creates a primitive parameter for the given parameter information reflection object.
@@ -102,7 +102,7 @@ public OpenApiParameter CreatePrimitiveParameter(string name, string description
: CreatePrimitiveOpenApiParameter(contextualParameter, typeDescription);
operationParameter.Name = name;
- operationParameter.IsRequired = contextualParameter.ContextAttributes.FirstAssignableToTypeNameOrDefault("RequiredAttribute", TypeNameStyle.Name) != null;
+ operationParameter.IsRequired = contextualParameter.GetContextAttributes(true).FirstAssignableToTypeNameOrDefault("RequiredAttribute", TypeNameStyle.Name) != null;
operationParameter.IsNullableRaw = typeDescription.IsNullable;
if (description != string.Empty)
diff --git a/src/NSwag.Generation/OpenApiSchemaGenerator.cs b/src/NSwag.Generation/OpenApiSchemaGenerator.cs
index 5a0efbd9f1..2131ac8cd8 100644
--- a/src/NSwag.Generation/OpenApiSchemaGenerator.cs
+++ b/src/NSwag.Generation/OpenApiSchemaGenerator.cs
@@ -63,7 +63,7 @@ public override TSchemaType GenerateWithReferenceAndNullability(
JsonSchemaResolver schemaResolver, Action transformation = null)
{
contextualType = GenericResultWrapperTypes.RemoveGenericWrapperTypes(
- contextualType, t => t.TypeName, t => t.OriginalGenericArguments[0]);
+ contextualType, t => t.Name, t => t.OriginalGenericArguments[0]);
if (IsFileResponse(contextualType))
{
diff --git a/src/NSwag.Generation/Processors/DocumentTagsProcessor.cs b/src/NSwag.Generation/Processors/DocumentTagsProcessor.cs
index 92b35e43c0..6a01591ccd 100644
--- a/src/NSwag.Generation/Processors/DocumentTagsProcessor.cs
+++ b/src/NSwag.Generation/Processors/DocumentTagsProcessor.cs
@@ -33,7 +33,7 @@ private static void ProcessTagsAttribute(OpenApiDocument document, Type controll
{
dynamic tagsAttribute = controllerType
.ToCachedType()
- .InheritedAttributes
+ .GetAttributes(true)
.FirstAssignableToTypeNameOrDefault("SwaggerTagsAttribute", TypeNameStyle.Name);
if (tagsAttribute != null)
@@ -64,7 +64,7 @@ private static void ProcessTagAttributes(OpenApiDocument document, Type controll
{
var tagAttributes = controllerType
.ToCachedType()
- .InheritedAttributes
+ .GetAttributes(true)
.GetAssignableToTypeName("SwaggerTagAttribute", TypeNameStyle.Name)
.Select(a => (dynamic)a)
.ToArray();
diff --git a/src/NSwagStudio/NSwagStudio.csproj b/src/NSwagStudio/NSwagStudio.csproj
index ac6d5f1564..91936de39e 100644
--- a/src/NSwagStudio/NSwagStudio.csproj
+++ b/src/NSwagStudio/NSwagStudio.csproj
@@ -61,7 +61,7 @@
-
+