public WebApiGeneratorModel BuildModel() { classesNames = new Collection <string>(); warnings = new Dictionary <string, string>(); enums = new Dictionary <string, ApiEnum>(); ParseSchemas(); schemaRequestObjects = GetRequestObjects(); schemaResponseObjects = GetResponseObjects(); CleanProperties(schemaObjects); CleanProperties(schemaRequestObjects); CleanProperties(schemaResponseObjects); webApiMethodsGenerator = new WebApiMethodsGenerator(raml, schemaResponseObjects, schemaRequestObjects, linkKeysWithObjectNames, schemaObjects); var controllers = GetControllers().ToArray(); CleanNotUsedObjects(controllers); return(new WebApiGeneratorModel { Namespace = NetNamingMapper.GetNamespace(raml.Title), Controllers = controllers, SchemaObjects = schemaObjects, RequestObjects = schemaRequestObjects, ResponseObjects = schemaResponseObjects, Warnings = warnings, Enums = 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 }); }
private void HandleParameters(Options opts, out string destinationFolder, out string targetFileName, out string targetNamespace) { destinationFolder = opts.DestinationFolder ?? "generated"; targetFileName = Path.GetFileName(opts.Source); if (string.IsNullOrWhiteSpace(targetFileName)) { targetFileName = "root.raml"; } if (!targetFileName.EndsWith(".raml")) { targetFileName += ".raml"; } targetNamespace = string.IsNullOrWhiteSpace(opts.Namespace) ? NetNamingMapper.GetNamespace(Path.GetFileNameWithoutExtension(targetFileName)) : opts.Namespace; }
public WebApiGeneratorModel BuildModel() { classesNames = new Collection <string>(); warnings = new Dictionary <string, string>(); schemaRequestObjects = GetRequestObjects(); schemaResponseObjects = GetResponseObjects(); CleanProperties(schemaRequestObjects); CleanProperties(schemaResponseObjects); var controllers = GetControllers(); return(new WebApiGeneratorModel { Namespace = NetNamingMapper.GetNamespace(raml.Title), Controllers = controllers, RequestObjects = schemaRequestObjects, ResponseObjects = schemaResponseObjects, Warnings = warnings }); }
public ModelsGeneratorModel BuildModel() { classesNames = new Collection <string>(); warnings = new Dictionary <string, string>(); enums = new Dictionary <string, ApiEnum>(); var ns = string.IsNullOrWhiteSpace(raml.Title) ? targetNamespace : NetNamingMapper.GetNamespace(raml.Title); new RamlTypeParser(raml.Types, schemaObjects, ns, enums, warnings).Parse(); ParseSchemas(); schemaRequestObjects = GetRequestObjects(); schemaResponseObjects = GetResponseObjects(); return(new ModelsGeneratorModel { SchemaObjects = schemaObjects, RequestObjects = schemaRequestObjects, ResponseObjects = schemaResponseObjects, Warnings = warnings, Enums = Enums }); }
public WebApiGeneratorModel BuildModel() { classesNames = new Collection <string>(); warnings = new Dictionary <string, string>(); enums = new Dictionary <string, ApiEnum>(); var ns = string.IsNullOrWhiteSpace(raml.Title) ? targetNamespace : NetNamingMapper.GetNamespace(raml.Title); new RamlTypeParser(raml.Types, schemaObjects, ns, enums, warnings).Parse(); ParseSchemas(); schemaRequestObjects = GetRequestObjects(); schemaResponseObjects = GetResponseObjects(); CleanProperties(schemaObjects); CleanProperties(schemaRequestObjects); CleanProperties(schemaResponseObjects); webApiMethodsGenerator = new WebApiMethodsGenerator(raml, schemaResponseObjects, schemaRequestObjects, linkKeysWithObjectNames, schemaObjects); var controllers = GetControllers().ToArray(); CleanNotUsedObjects(controllers); return(new WebApiGeneratorModel { Namespace = ns, Controllers = controllers, SchemaObjects = schemaObjects, RequestObjects = schemaRequestObjects, ResponseObjects = schemaResponseObjects, Warnings = warnings, Enums = Enums, ApiVersion = raml.Version }); }
public void Should_Remove_Dash_From_Namespace() { Assert.Equal("GetSales", NetNamingMapper.GetNamespace("get-sales")); }