コード例 #1
0
        private void HandleAsObjectParameters(SwaggerOperation operation, DotvvmCSharpOperationModel model, ClientGeneratorBaseSettings settings)
        {
            // find groups of parameters that should be treated as one
            var parameters = model.QueryParameters.Where(p => p.Name.Contains(".") && p.Schema.ExtensionData.ContainsKey("x-dotvvm-wrapperType"));
            var groups     = parameters.GroupBy(p => p.Name.Substring(0, p.Name.IndexOf("."))).ToList();

            foreach (var g in groups)
            {
                var typeName = g.First().Schema.ExtensionData["x-dotvvm-wrapperType"].ToString();
                typeName = typeName.Substring(0, typeName.IndexOf(","));

                var swaggerParameter = new SwaggerParameter()
                {
                    Name   = g.Key,
                    Schema = new JsonSchema4(),
                    Kind   = SwaggerParameterKind.Query
                };
                var newParameter = new DotvvmCSharpParameterModel(g.Key, g.Key, typeName, swaggerParameter, operation.Parameters, settings.CodeGeneratorSettings, this, model)
                {
                    ExcludeFromQuery = true
                };
                var targetIndex = g.Min(p => model.Parameters.IndexOf(p));
                foreach (var p in g)
                {
                    ((DotvvmCSharpParameterModel)p).CustomInitializer = $"var {p.VariableName} = {g.Key} != null ? {p.Name} : default({p.Type});";
                }
                model.Parameters.Insert(targetIndex, newParameter);
            }
        }
コード例 #2
0
        protected override CSharpOperationModel CreateOperationModel(SwaggerOperation operation, ClientGeneratorBaseSettings settings)
        {
            var model = new DotvvmCSharpOperationModel(operation, Settings, this, resolver);

            HandleAsObjectParameters(operation, model, settings);
            return(model);
        }
コード例 #3
0
        protected override CSharpOperationModel CreateOperationModel(SwaggerOperation operation, ClientGeneratorBaseSettings settings)
        {
            var model = new DotvvmCSharpOperationModel(operation, Settings, this, resolver);

            HandleAsObjectParameters(operation, model, settings);

            model.AutoRefreshKey = string.Join("/", document.Operations.Single(o => o.Operation.OperationId == operation.OperationId).Operation.Tags);

            return(model);
        }
コード例 #4
0
 public DotvvmCSharpParameterModel(string parameterName, string variableName, string typeName, SwaggerParameter parameter, IList <SwaggerParameter> allParameters, CodeGeneratorSettingsBase settings, IClientGenerator generator, DotvvmCSharpOperationModel operation) : base(parameterName, variableName, typeName, parameter, allParameters, settings, generator)
 {
     this.operation = operation;
 }