protected Parameter BuildParameter(RequestParameter requestParameter) { var type = _typeFactory.CreateType(requestParameter.Schema, requestParameter.IsNullable()); var isRequired = requestParameter.Required == true; var defaultValue = ParseConstant(requestParameter); if (!isRequired && defaultValue == null) { defaultValue = Constant.Default(type); } return(new Parameter( requestParameter.CSharpName(), CreateDescription(requestParameter), TypeFactory.GetInputType(type), defaultValue, isRequired)); }
private Constant?ParseConstant(RequestParameter parameter) { if (parameter.ClientDefaultValue != null) { CSharpType constantTypeReference = _context.TypeFactory.CreateType(parameter.Schema, parameter.IsNullable()); return(BuilderHelpers.ParseConstant(parameter.ClientDefaultValue, constantTypeReference)); } if (parameter.Schema is ConstantSchema constantSchema) { return(ParseConstant(constantSchema)); } return(null); }