Ejemplo n.º 1
0
        public void Apply(
            ApiDescription apiDescription,
            OperationSpec operationSpec,
            ModelSpecRegistrar modelSpecRegistrar,
            ModelSpecGenerator modelSpecGenerator)
        {
            var responseTypeAttr = apiDescription.ActionDescriptor.GetCustomAttributes<ResponseTypeAttribute>().FirstOrDefault();
            if (responseTypeAttr == null) return;

            IEnumerable<ModelSpec> complexSpecs;
            var modelSpec = modelSpecGenerator.TypeToModelSpec(responseTypeAttr.Type, out complexSpecs);

            if (modelSpec.Type == "object")
            {
                operationSpec.Type = modelSpec.Id;
            }
            else
            {
                operationSpec.Type = modelSpec.Type;
                operationSpec.Format = modelSpec.Format;
                operationSpec.Items = modelSpec.Items;
                operationSpec.Enum = modelSpec.Enum;
            }
            modelSpecRegistrar.RegisterMany(complexSpecs);
        }
        public OperationSpecGenerator(
            IDictionary<Type, ModelSpec> customTypeMappings,
            IEnumerable<IOperationFilter> operationFilters,
            IEnumerable<IOperationSpecFilter> operationSpecFilters)
        {
            _operationFilters = operationFilters;
            _operationSpecFilters = operationSpecFilters;

            _modelSpecGenerator = new ModelSpecGenerator(customTypeMappings);
        }
Ejemplo n.º 3
0
        public OperationSpecGenerator(
            IDictionary <Type, ModelSpec> customTypeMappings,
            Dictionary <Type, IEnumerable <Type> > subTypesLookup,
            IEnumerable <IOperationFilter> operationFilters,
            IEnumerable <IOperationSpecFilter> operationSpecFilters)
        {
            _operationFilters     = operationFilters;
            _operationSpecFilters = operationSpecFilters;

            _modelSpecGenerator = new ModelSpecGenerator(customTypeMappings, subTypesLookup);
        }
Ejemplo n.º 4
0
 public ModelSpecMap(ModelSpecRegistrar modelSpecRegistrar, ModelSpecGenerator modelSpecGenerator)
 {
     _modelSpecRegistrar = modelSpecRegistrar;
     _modelSpecGenerator = modelSpecGenerator;
 }