private void ParseComplexTypes(IDictionary <string, ApiObject> objects, JsonSchema schema, Property prop, KeyValuePair <string, JsonSchema> property, string key, IDictionary <string, ApiEnum> enums) { if (schema.Type.HasValue && (schema.Type == JsonSchemaType.Object || schema.Type.Value.ToString().Contains("Object"))) { if (!string.IsNullOrWhiteSpace(schema.Id) && ids.Contains(schema.Id)) { return; } if (!string.IsNullOrWhiteSpace(schema.Id)) { ids.Add(schema.Id); } var type = string.IsNullOrWhiteSpace(property.Value.Id) ? key : property.Value.Id; type = ParseObject(type, schema, objects, enums); if (type != null) { prop.Type = NetNamingMapper.GetObjectName(type); } return; } if (schema.Type == JsonSchemaType.Array) { ParseArray(objects, schema, prop, property, enums); } }
private ClientGeneratorMethod BuildClassMethod(string url, Method method, Resource resource) { var parentUrl = UrlGeneratorHelper.GetParentUri(url, resource.RelativeUri); var generatedMethod = new ClientGeneratorMethod { Name = NetNamingMapper.GetMethodName(method.Verb ?? "Get" + resource.RelativeUri), ReturnType = GetReturnType(GeneratorServiceHelper.GetKeyForResource(method, resource, parentUrl), method, resource, url), Parameter = GetParameter(GeneratorServiceHelper.GetKeyForResource(method, resource, parentUrl), method, resource, url), Comment = GetComment(resource, method), Url = url, Verb = NetNamingMapper.Capitalize(method.Verb), Parent = null, UseSecurity = raml.SecuredBy != null && raml.SecuredBy.Any() || resource.Methods.Any(m => m.Verb == method.Verb && m.SecuredBy != null && m.SecuredBy.Any()), RequestContentTypes = method.Body.Keys.ToArray(), ResponseContentTypes = method.Responses != null?method.Responses.Where(r => r.Body != null).SelectMany(r => r.Body.Keys).ToArray() : new string[0] }; // look in traits // look in resource types return(generatedMethod); }
private string ParseEnum(string key, Newtonsoft.JsonV4.Schema.JsonSchema schema, IDictionary <string, ApiEnum> enums, string description) { var name = NetNamingMapper.GetObjectName(key); var apiEnum = new ApiEnum { Name = name, Description = description, Values = schema.Enum.Select(e => NetNamingMapper.GetEnumValueName(e.ToString())).ToList() }; if (enums.ContainsKey(name)) { if (IsAlreadyAdded(enums, apiEnum)) { return(name); } apiEnum.Name = UniquenessHelper.GetUniqueName(enums, name); } enums.Add(apiEnum.Name, apiEnum); return(apiEnum.Name); }
protected string GetUniqueName(ICollection <string> methodsNames, string methodName, string relativeUri) { var nameWithResource = NetNamingMapper.GetMethodName(methodName + relativeUri); if (!methodsNames.Contains(nameWithResource)) { return(nameWithResource); } for (var i = 0; i < 7; i++) { var unique = methodName + suffixes[i]; if (!methodsNames.Contains(unique)) { return(unique); } } for (var i = 0; i < 100; i++) { var unique = methodName + i; if (!methodsNames.Contains(unique)) { return(unique); } } throw new InvalidOperationException("Could not find a unique name for method " + methodName); }
private string GetParameterName(string name) { var res = NetNamingMapper.GetObjectName(name); res = res.Substring(0, 1).ToLowerInvariant() + res.Substring(1); return(res); }
private ControllerMethod BuildControllerMethod(string url, Operation method, Parser.Model.EndPoint resource, ControllerObject parent, IDictionary <string, Parameter> parentUriParameters, string modelsNamespace) { var relativeUri = UrlGeneratorHelper.GetRelativeUri(url, parent.PrefixUri); var parentUrl = UrlGeneratorHelper.GetParentUri(url, resource.Path); var operationWithSecurity = resource.Operations.FirstOrDefault(m => m.Method == method.Method && m.Security != null && m.Security.Any()); var securedBy = operationWithSecurity?.Security.Select(s => s.Name).ToArray(); return(new ControllerMethod { ModelsNamespace = modelsNamespace, Name = NetNamingMapper.GetMethodName(method.Method ?? "Get" + resource.Path), Parameter = GetParameter(GeneratorServiceHelper.GetKeyForResource(method, resource), method, resource, url), UriParameters = uriParametersGenerator.GetUriParameters(resource, url, parentUriParameters), ResponseStatusCode = method.Responses != null && method.Responses.Count() == 1 ? method.Responses.First().StatusCode : null, ReturnType = GetReturnType(method, resource, url), Comment = GetComment(resource, method, url), Url = relativeUri, Verb = NetNamingMapper.Capitalize(method.Method), Parent = null, UseSecurity = resource.Operations.Any(m => m.Method == method.Method && m.Security != null && m.Security.Any()), SecuredBy = securedBy, SecurityParameters = GetSecurityParameters(method) }); }
private ClientGeneratorMethod BuildClassMethod(string url, Operation operation, RAML.Parser.Model.EndPoint resource, string modelsNamespace) { var parentUrl = UrlGeneratorHelper.GetParentUri(url, resource.Path); //TODO: check var responseContentTypes = operation.Responses != null? operation.Responses.Where(r => r.Payloads != null).SelectMany(r => r.Payloads).Select(p => p.MediaType).ToArray() : new string[0]; var generatedMethod = new ClientGeneratorMethod { ModelsNamespace = modelsNamespace, Name = NetNamingMapper.GetMethodName(operation.Method ?? "Get" + resource.Path), ReturnType = GetReturnType(operation, resource, url), Parameter = GetParameter(GeneratorServiceHelper.GetKeyForResource(operation, resource), operation, resource, url), Comment = GetComment(resource, operation, url), Url = url, Verb = NetNamingMapper.Capitalize(operation.Method), Parent = null, UseSecurity = resource.Operations.Any(m => m.Method == operation.Method && m.Security != null && m.Security.Any()), RequestContentTypes = operation.ContentType, ResponseContentTypes = responseContentTypes }; // look in traits // look in resource types return(generatedMethod); }
private void SetPreview(RamlDocument document) { Execute.OnUIThreadAsync(() => { try { ResourcesPreview = GetResourcesPreview(document); StopProgress(); SetNamespace(RamlTempFilePath); if (document.Version != null) { ApiVersion = NetNamingMapper.GetVersionName(document.Version); } CanImport = true; if (NetNamingMapper.HasIndalidChars(Filename)) { ShowErrorAndStopProgress("The specied file name has invalid chars"); // txtFileName.Focus(); } } catch (Exception ex) { ShowErrorAndStopProgress("Error while parsing raml file. " + ex.Message); logger.LogError(VisualStudioAutomationHelper.RamlVsToolsActivityLogSource, VisualStudioAutomationHelper.GetExceptionInfo(ex)); } }); }
private void AddProperty(RAML.Parser.Model.EndPoint resource, Operation method, string key, Response response, ICollection <Property> properties, string fullUrl) { var mimeType = GeneratorServiceHelper.GetMimeType(response); if (mimeType == null) { return; } var type = responseTypesService.GetResponseType(method, resource, mimeType, key, response.StatusCode, fullUrl); if (string.IsNullOrWhiteSpace(type)) { return; } var name = NetNamingMapper.GetPropertyName(CollectionTypeHelper.GetBaseType(type)); if (properties.Any(p => p.Name == name)) { name = name + response.StatusCode; } var property = new Property { Name = name, Description = response.Description + " " + mimeType.Schema.Description, Example = ObjectParser.MapExample(mimeType.Schema), Type = type, StatusCode = GetStatusCode(response), JSONSchema = mimeType.Schema as SchemaShape == null ? null : ((SchemaShape)mimeType.Schema).Raw.Replace(Environment.NewLine, "").Replace("\r\n", "").Replace("\n", "").Replace("\"", "\\\"") }; properties.Add(property); }
private string HandleMultipleSchemaType(IEnumerable <Response> responses, RAML.Parser.Model.EndPoint resource, Operation method, string fullUrl) { var properties = GetProperties(responses, resource, method, fullUrl); if (properties.Count == 0) { return("string"); } if (properties.Count == 1) { return(properties.First().Type); } // Build a new response object containing all types var key = GeneratorServiceHelper.GetKeyForResource(method, resource); var name = NetNamingMapper.GetObjectName("Multiple" + key); var apiObject = new ApiObject { Name = name, Description = "Multiple Response Types " + string.Join(", ", properties.Select(p => p.Name)), Properties = properties, IsMultiple = true }; schemaResponseObjects.Add(new KeyValuePair <string, ApiObject>(name, apiObject)); return(name); }
private void ParseArray(IDictionary <string, ApiObject> objects, JsonSchema schema, Property prop, KeyValuePair <string, JsonSchema> property, IDictionary <string, ApiEnum> enums) { if (schema.Items == null || !schema.Items.Any()) { return; } var netType = NetTypeMapper.GetNetType(schema.Items.First().Type, property.Value.Format); if (netType != null) { prop.Type = CollectionTypeHelper.GetCollectionType(netType); } else { prop.Type = CollectionTypeHelper.GetCollectionType(NetNamingMapper.GetObjectName(property.Key)); foreach (var item in schema.Items) { var modifiedKey = ParseObject(property.Key, item, objects, enums); if (modifiedKey != null) { prop.Type = CollectionTypeHelper.GetCollectionType(NetNamingMapper.GetObjectName(modifiedKey)); } } } }
private string ParseObject(string key, Newtonsoft.JsonV4.Schema.JsonSchema schema, IDictionary <string, ApiObject> objects, IDictionary <string, ApiEnum> enums, Newtonsoft.JsonV4.Schema.JsonSchema parentSchema, string baseClass = null) { var propertiesSchemas = schema.Properties; var obj = new ApiObject { Name = NetNamingMapper.GetObjectName(key), Properties = ParseSchema(propertiesSchemas, objects, enums, parentSchema), BaseClass = baseClass }; AdditionalProperties(obj.Properties, schema); if (!obj.Properties.Any()) { return(null); } // Avoid duplicated keys and names if (objects.ContainsKey(key) || objects.Any(o => o.Value.Name == obj.Name) || otherObjects.ContainsKey(key) || otherObjects.Any(o => o.Value.Name == obj.Name) || schemaObjects.ContainsKey(key) || schemaObjects.Any(o => o.Value.Name == obj.Name)) { if (UniquenessHelper.HasSameProperties(obj, objects, key, otherObjects, schemaObjects)) { return(key); } obj.Name = UniquenessHelper.GetUniqueName(objects, obj.Name, otherObjects, schemaObjects); key = UniquenessHelper.GetUniqueKey(objects, key, otherObjects); } objects.Add(key, obj); return(key); }
private static string GetObjectNameForParameter(RAML.Parser.Model.EndPoint resource) { var relativeUri = resource.Path.Replace("{mediaTypeExtension}", string.Empty); var objectNameForParameter = relativeUri.Substring(1).Replace("{", string.Empty).Replace("}", string.Empty); objectNameForParameter = NetNamingMapper.GetObjectName(objectNameForParameter); return(objectNameForParameter); }
public void SetProperties(HttpResponseHeaders headers) { var properties = this.GetType().GetProperties().Where(p => p.GetValue(this) != null); foreach (var prop in properties.Where(prop => headers.Any(h => h.Key == prop.Name))) { prop.SetValue(this, headers.First(h => NetNamingMapper.GetPropertyName(h.Key) == prop.Name)); } }
public async void AddExistingRamlFromExchange() { var exchangeBrowseViewModel = new ExchangeBrowserViewModel(); WindowManager.ShowDialog(exchangeBrowseViewModel); var selectedAsset = exchangeBrowseViewModel.SelectedAsset; if (selectedAsset != null) { var file = selectedAsset.Files.FirstOrDefault(f => f.Classifier == "fat-raml"); if (file == null) { file = selectedAsset.Files.FirstOrDefault(f => f.Classifier == "raml"); } if (file == null) { MessageBox.Show("The selected REST API does not seem to have any RAML file associated"); return; } var uri = file.ExternalLink; var client = new HttpClient(); var byteArray = await client.GetByteArrayAsync(uri); var assetName = NetNamingMapper.GetObjectName(selectedAsset.Name); var zipPath = Path.Combine(Path.GetTempPath(), assetName + ".zip"); File.WriteAllBytes(zipPath, byteArray); var randInt = new Random().Next(short.MaxValue); var destinationFolder = Path.Combine(Path.GetTempPath(), assetName + randInt); ZipFile.ExtractToDirectory(zipPath, destinationFolder); RamlTempFilePath = GetRamlPath(destinationFolder, file.MainFile, uri); if (RamlTempFilePath == null) { MessageBox.Show("Unable to determine main RAML file, please use the 'Upload' option to choose the right file from folder " + destinationFolder); return; } var previewViewModel = new RamlPreviewViewModel(ServiceProvider, action, RamlTempFilePath, RamlTempFilePath, Path.GetFileName(RamlTempFilePath), isContractUseCase, useBasicAuth: false, username: string.Empty, password: string.Empty); try { StartProgress(); await previewViewModel.FromFile(); } finally { StopProgress(); } ShowPreviewViewAndClose(previewViewModel); } }
private void SetDefaultClientRootClassName() { var rootName = NetNamingMapper.GetObjectName(Path.GetFileNameWithoutExtension(RamlTempFilePath)); if (!rootName.ToLower().Contains("client")) { rootName += "Client"; } ProxyClientName = rootName; }
private ApiEnum ParseEnum(ScalarShape scalar, IDictionary <string, ApiEnum> existingEnums, IDictionary <string, string> warnings, IDictionary <string, ApiEnum> newEnums) { return(new ApiEnum { Name = NetNamingMapper.GetObjectName(scalar.Name), Description = scalar.Description, Values = scalar.Values.Select(p => new PropertyBase { Name = NetNamingMapper.GetEnumValueName(p), OriginalName = p }).ToArray() }); }
private static Property ConvertGeneratorParamToProperty(GeneratorParameter p) { return(new Property { Name = NetNamingMapper.Capitalize(p.Name), OriginalName = p.Name, Description = p.Description, Type = p.Type, Required = true }); }
public void Title_Changed() { if (string.IsNullOrWhiteSpace(title)) { return; } SelectNewRamlOption(); NewRamlFilename = NetNamingMapper.RemoveInvalidChars(Title) + RamlFileExtension; NewRamlNamespace = GetNamespace(NewRamlFilename); }
private static ClientGeneratorModel GetGeneratorModel(string wszInputFilePath, RamlInfo ramlInfo) { var rootName = NetNamingMapper.GetObjectName(Path.GetFileNameWithoutExtension(wszInputFilePath)); if (!rootName.ToLower().Contains("api")) { rootName += "Api"; } var model = new ClientGeneratorService(ramlInfo.RamlDocument, rootName).BuildModel(); return(model); }
public static string DecodeRaml1Type(string type) { // TODO: can I handle this better ? if (type.Contains("(") || type.Contains("|")) { return("object"); } if (type.EndsWith("[][]")) // array of arrays { var strippedType = type.Substring(0, type.Length - 4); if (NewNetTypeMapper.Map(strippedType) == null) { strippedType = NetNamingMapper.GetObjectName(strippedType); } var decodeRaml1Type = CollectionTypeHelper.GetCollectionType(CollectionTypeHelper.GetCollectionType(strippedType)); return(decodeRaml1Type); } if (type.EndsWith("[]")) // array { var strippedType = type.Substring(0, type.Length - 2); if (NewNetTypeMapper.Map(strippedType) == null) { strippedType = NetNamingMapper.GetObjectName(strippedType); } var decodeRaml1Type = CollectionTypeHelper.GetCollectionType(strippedType); return(decodeRaml1Type); } if (type.EndsWith("{}")) // Map { var subtype = type.Substring(0, type.Length - 2); var netType = NewNetTypeMapper.Map(subtype); if (netType != null) { return("IDictionary<string, " + netType + ">"); } return("IDictionary<string, " + NetNamingMapper.GetObjectName(subtype) + ">"); } if (CollectionTypeHelper.IsCollection(type)) { return(type); } return(NetNamingMapper.GetObjectName(type)); }
private static string GetCollectionType(Property prop, string itemType) { if (NewNetTypeMapper.IsPrimitiveType(itemType)) { return(CollectionTypeHelper.GetCollectionType(itemType)); } if (CollectionTypeHelper.IsCollection(itemType)) { return(CollectionTypeHelper.GetCollectionType(itemType)); } return(CollectionTypeHelper.GetCollectionType(NetNamingMapper.GetObjectName(itemType))); }
private void ParseComplexTypes(IDictionary <string, ApiObject> objects, Newtonsoft.JsonV4.Schema.JsonSchema schema, Newtonsoft.JsonV4.Schema.JsonSchema propertySchema, Property prop, KeyValuePair <string, Newtonsoft.JsonV4.Schema.JsonSchema> property, IDictionary <string, ApiEnum> enums) { if (propertySchema.Type.HasValue && (propertySchema.Type == Newtonsoft.JsonV4.Schema.JsonSchemaType.Object || propertySchema.Type.Value.ToString().Contains("Object")) && propertySchema.Properties != null) { if (!string.IsNullOrWhiteSpace(schema.Id) && ids.Contains(schema.Id)) { return; } if (!string.IsNullOrWhiteSpace(schema.Id)) { ids.Add(schema.Id); } var type = string.IsNullOrWhiteSpace(property.Value.Id) ? property.Key : property.Value.Id; ParseObject(type, propertySchema.Properties, objects, enums, propertySchema); prop.Type = NetNamingMapper.GetObjectName(type); } else if (propertySchema.Type.HasValue && propertySchema.Type == Newtonsoft.JsonV4.Schema.JsonSchemaType.Object && propertySchema.OneOf != null && propertySchema.OneOf.Count > 0 && schema.Definitions != null && schema.Definitions.Count > 0) { string baseTypeName = NetNamingMapper.GetObjectName(property.Key); if (schemaObjects.ContainsKey(baseTypeName) || objects.ContainsKey(baseTypeName) || otherObjects.ContainsKey(baseTypeName)) { return; } objects.Add(baseTypeName, new ApiObject { Name = baseTypeName, Properties = new List <Property>() }); foreach (var innerSchema in propertySchema.OneOf) { var definition = schema.Definitions.FirstOrDefault(k => k.Value == innerSchema); ParseObject(property.Key + definition.Key, innerSchema.Properties, objects, enums, innerSchema, baseTypeName); } prop.Type = baseTypeName; } else if (propertySchema.Type == Newtonsoft.JsonV4.Schema.JsonSchemaType.Array) { ParseArray(objects, propertySchema, prop, property, enums); } }
public ClientGeneratorModel BuildModel() { warnings = new Dictionary <string, string>(); classesNames = new Collection <string>(); classes = new Collection <ClassObject>(); classesObjectsRegistry = new Dictionary <string, ClassObject>(); uriParameterObjects = new Dictionary <string, ApiObject>(); schemaRequestObjects = GetRequestObjects(); schemaResponseObjects = GetResponseObjects(); CleanProperties(schemaRequestObjects); CleanProperties(schemaResponseObjects); var parentClass = new ClassObject { Name = rootClassName, Description = "Main class for grouping root resources. Nested resources are defined as properties. The constructor can optionally receive an URL and HttpClient instance to override the default ones." }; classesNames.Add(parentClass.Name); classes.Add(parentClass); classesObjectsRegistry.Add(rootClassName, parentClass); var classObjects = GetClasses(raml.Resources, null, parentClass, null); SetClassesProperties(classesObjectsRegistry[rootClassName]); var apiRequestObjects = apiRequestGenerator.Generate(classObjects); var apiResponseObjects = apiResponseGenerator.Generate(classObjects); return(new ClientGeneratorModel { Namespace = NetNamingMapper.GetNamespace(raml.Title), RequestObjects = schemaRequestObjects, ResponseObjects = schemaResponseObjects, QueryObjects = queryObjects, HeaderObjects = headerObjects, ApiRequestObjects = apiRequestObjects, ApiResponseObjects = apiResponseObjects, ResponseHeaderObjects = responseHeadersObjects, BaseUriParameters = ParametersMapper.Map(raml.BaseUriParameters), BaseUri = raml.BaseUri, Security = SecurityParser.GetSecurity(raml), Version = raml.Version, Warnings = warnings, Classes = classObjects.Where(c => c.Name != rootClassName).ToArray(), Root = classObjects.First(c => c.Name == rootClassName), UriParameterObjects = uriParameterObjects }); }
public void Generate(EndPoint resource, string url, ClientGeneratorMethod clientGeneratorMethod, IDictionary <string, ApiObject> uriParameterObjects, IDictionary <string, Parameter> parentUriParameters) { var parameters = GetUriParameters(resource, url, parentUriParameters).ToArray(); clientGeneratorMethod.UriParameters = parameters; if (!parameters.Any()) { return; } var name = NetNamingMapper.GetObjectName(url) + "UriParameters"; clientGeneratorMethod.UriParametersType = name; if (uriParameterObjects.ContainsKey(name)) { return; } var properties = new List <Property>(); if (resource.Parameters != null) { properties.AddRange(queryParametersParser.ConvertParametersToProperties(resource.Parameters)); } var urlParameters = ExtractParametersFromUrl(url).ToArray(); var matchedParameters = MatchParameters(parentUriParameters, urlParameters); foreach (var urlParameter in matchedParameters) { var property = ConvertGeneratorParamToProperty(urlParameter); if (properties.All(p => !String.Equals(property.Name, p.Name, StringComparison.InvariantCultureIgnoreCase))) { properties.Add(property); } } var apiObject = new ApiObject { Name = name, Description = "Uri Parameters for resource " + resource.Path, Properties = properties }; uriParameterObjects.Add(name, apiObject); }
private static string GetType(KeyValuePair <string, JsonSchema> property, bool isEnum, string enumName) { if (isEnum) { return(enumName); } var type = NetTypeMapper.Map(property.Value.Type); if (!string.IsNullOrWhiteSpace(type)) { if (type == "string" || (property.Value.Required != null && property.Value.Required.Value)) { return(type); } return(type + "?"); } if (HasMultipleTypes(property)) { return(HandleMultipleTypes(property)); } if (!string.IsNullOrWhiteSpace(property.Value.Id)) { return(NetNamingMapper.GetObjectName(property.Value.Id)); } // if it is a "body less" array then I assume it's an array of strings if (property.Value.Type == JsonSchemaType.Array && (property.Value.Items == null || !property.Value.Items.Any())) { return(CollectionTypeHelper.GetCollectionType("string")); } // if it is a "body less" object then use object as the type if (property.Value.Type == JsonSchemaType.Object && (property.Value.Properties == null || !property.Value.Properties.Any())) { return("object"); } if (property.Value == null) { return(null); } return(NetNamingMapper.GetObjectName(property.Key)); }
private static Property CreateProperty(Newtonsoft.JsonV4.Schema.JsonSchema schema, KeyValuePair <string, Newtonsoft.JsonV4.Schema.JsonSchema> property, bool isEnum, string enumName) { return(new Property { Name = NetNamingMapper.GetPropertyName(property.Key), Type = GetType(property, isEnum, enumName, schema.Required), OriginalName = property.Key, Description = property.Value.Description, IsEnum = isEnum, Required = schema.Required != null && schema.Required.Contains(property.Key), MaxLength = property.Value.MaximumLength, MinLength = property.Value.MinimumLength, Maximum = property.Value.Maximum, Minimum = property.Value.Minimum }); }
private static Property CreateProperty(string key, string type, KeyValuePair <string, JsonSchema> property, bool isEnum) { return(new Property { Name = NetNamingMapper.GetPropertyName(key), OriginalName = key, Type = type, Description = property.Value.Description, IsEnum = isEnum, MaxLength = property.Value.MaximumLength, MinLength = property.Value.MinimumLength, Maximum = property.Value.Maximum, Minimum = property.Value.Minimum, Required = property.Value.Required != null && property.Value.Required.Value }); }
private void ParseArray(IDictionary <string, ApiObject> objects, Newtonsoft.JsonV4.Schema.JsonSchema schema, Property prop, KeyValuePair <string, Newtonsoft.JsonV4.Schema.JsonSchema> property, IDictionary <string, ApiEnum> enums) { var netType = NetTypeMapper.Map(schema.Items.First().Type); if (netType != null) { prop.Type = CollectionTypeHelper.GetCollectionType(netType); } else { prop.Type = CollectionTypeHelper.GetCollectionType(NetNamingMapper.GetObjectName(property.Key)); foreach (var item in schema.Items) { ParseObject(property.Key, item.Properties, objects, enums, item); } } }
public void SaveButton() { if (Namespace == null || NetNamingMapper.HasIndalidChars(Namespace)) { MessageBox.Show("Error: invalid namespace."); return; } if (clientName != null && NetNamingMapper.HasIndalidChars(ClientName)) { MessageBox.Show("Error: invalid client name."); return; } if (source != null && NetNamingMapper.HasIndalidChars(source)) { MessageBox.Show("Error: invalid source."); return; } if (HasInvalidPath(ModelsFolder)) { MessageBox.Show("Error: invalid path specified for models. Path must be relative."); return; } if (HasInvalidPath(ImplementationControllersFolder)) { MessageBox.Show("Error: invalid path specified for controllers. Path must be relative."); return; } var ramlProperties = new RamlProperties { Namespace = Namespace, Source = Source, ClientName = ClientName, UseAsyncMethods = UseAsyncMethods, IncludeApiVersionInRoutePrefix = IncludeApiVersionInRoutePrefix, ModelsFolder = ModelsFolder, AddGeneratedSuffix = AddGeneratedSuffixToFiles, ImplementationControllersFolder = ImplementationControllersFolder }; RamlPropertiesManager.Save(ramlProperties, ramlPath); WasSaved = true; TryClose(); }