private void ExecuteAttributePropertyHandlers(Operation operation, DataTypeRegistry dataTypeRegistry, ApiDescription apiDescription, SwaggerAttribute attribute) { AttributePropertyHandler.AsParallel().ForAll(p => { var propertyInfo = typeof(SwaggerAttribute).GetProperty(p.Key); if (propertyInfo == null) return; var handler = (ISwaggerAttributeHandler)(Activator.CreateInstance(p.Value)); handler.Handle(operation, dataTypeRegistry, apiDescription, attribute); }); }
public void Handle(Operation operation, DataTypeRegistry dataTypeRegistry, ApiDescription apiDescription, SwaggerAttribute attribute) { var responseType = attribute.ResponseClassType; if (responseType == null || responseType == typeof(void)) { operation.Type = "void"; return; } var dataType = dataTypeRegistry.GetOrRegister(responseType); if (dataType.Type == "object") { operation.Type = dataType.Id; } else { operation.Type = dataType.Type; operation.Format = dataType.Format; operation.Items = dataType.Items; operation.Enum = dataType.Enum; } }