示例#1
0
        public static WebApi Map(IDictionary <string, object> model)
        {
            if (model == null)
            {
                return(null);
            }

            var name        = model["name"] as string;
            var description = model["description"] as string;
            var host        = model["host"] as string;
            IEnumerable <string>   schemes     = StringEnumerationMapper.Map(model["schemes"] as object[]);
            IEnumerable <EndPoint> endPoints   = EndPointMapper.Map(model["endpoints"] as object[]);
            IEnumerable <string>   servers     = StringEnumerationMapper.Map(model["servers"] as object[]);
            IEnumerable <string>   accepts     = StringEnumerationMapper.Map(model["accepts"] as object[]);
            IEnumerable <string>   contentType = StringEnumerationMapper.Map(model["contentType"] as object[]);
            string       version        = model["version"] as string;
            string       termsOfService = model["termsOfService"] as string;
            Organization provider       = OrganizationMapper.Map(model["provider"] as IDictionary <string, object>);
            License      license        = LicenseMapper.Map(model["license"] as IDictionary <string, object>);
            IEnumerable <Documentation> documentations        = DocumentationMapper.Map(model["documentations"] as object[]);
            IEnumerable <Parameter>     baseUriParameters     = ParameterMapper.Map(model["baseUriParameters"] as object[]);
            IEnumerable <ParametrizedSecurityScheme> security = ParametrizedSecuritySchemeMapper.Map(model["security"] as object[]);

            return(new WebApi(name, description, host, schemes, endPoints, servers, accepts, contentType, version, termsOfService,
                              provider, license, documentations, baseUriParameters, security));
        }
示例#2
0
        private static EndPoint Map(IDictionary <string, object> endpoint)
        {
            if (endpoint == null)
            {
                return(null);
            }

            return(new EndPoint(endpoint["name"] as string, endpoint["description"] as string, endpoint["path"] as string,
                                OperationMapper.Map(endpoint["operations"] as object[]), ParameterMapper.Map(endpoint["parameters"] as object[]),
                                ParametrizedSecuritySchemeMapper.Map(endpoint["security"] as object[])));
        }