public Method Build(IDictionary <string, object> dynamicRaml, string defaultMediaType) { var method = new Method(); new BasicInfoBuilder().Set(dynamicRaml, method); method.Verb = dynamicRaml.ContainsKey("method") ? (string)dynamicRaml["method"] : null; method.Headers = dynamicRaml.ContainsKey("headers") ? new ParametersBuilder(dynamicRaml["headers"] as IDictionary <string, object>).GetAsDictionary() : new Dictionary <string, Parameter>(); method.Responses = dynamicRaml.ContainsKey("responses") ? new ResponsesBuilder(dynamicRaml["responses"] as IDictionary <string, object>).Get(defaultMediaType) : new List <Response>(); method.QueryParameters = dynamicRaml.ContainsKey("queryParameters") ? new ParametersBuilder((IDictionary <string, object>)dynamicRaml["queryParameters"]).GetAsDictionary() : null; method.Body = dynamicRaml.ContainsKey("body") ? new BodyBuilder((IDictionary <string, object>)dynamicRaml["body"]).GetAsDictionary(defaultMediaType) : new Dictionary <string, MimeType>(); method.BaseUriParameters = ParametersBuilder.GetUriParameters(dynamicRaml, "baseUriParameters"); method.SecuredBy = GetSecuredBy(dynamicRaml); method.Protocols = ProtocolsBuilder.Get(dynamicRaml); method.Is = IsExtractor.Get(dynamicRaml); method.Description = dynamicRaml.ContainsKey("description") ? (string)dynamicRaml["description"] : null; method.Annotations = AnnotationsBuilder.GetAnnotations(dynamicRaml); return(method); }
public Resource Build(IDictionary <string, object> dynamicRaml, IEnumerable <IDictionary <string, ResourceType> > resourceTypes, IEnumerable <IDictionary <string, Method> > traits, string defaultMediaType) { var resource = new Resource(); new BasicInfoBuilder().Set(dynamicRaml, resource); resource.RelativeUri = dynamicRaml.ContainsKey("relativeUri") ? (string)dynamicRaml["relativeUri"] : null; resource.BaseUriParameters = ParametersBuilder.GetUriParameters(dynamicRaml, "baseUriParameters"); resource.UriParameters = ParametersBuilder.GetUriParameters(dynamicRaml, "uriParameters"); resource.DisplayName = dynamicRaml.ContainsKey("displayName") ? (string)dynamicRaml["displayName"] : null; resource.Protocols = ProtocolsBuilder.Get(dynamicRaml); resource.Resources = GetResources(dynamicRaml, resourceTypes, traits, defaultMediaType); resource.Methods = GetMethods(dynamicRaml, traits, defaultMediaType); resource.Annotations = AnnotationsBuilder.GetAnnotations(dynamicRaml); resource.Is = IsExtractor.Get(dynamicRaml); return(resource); }