예제 #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
        internal static Request Map(IDictionary <string, object> request)
        {
            if (request == null)
            {
                return(null);
            }

            return(new Request(ParameterMapper.Map(request["queryParameters"] as object[]), ParameterMapper.Map(request["headers"] as object[]),
                               PayloadMapper.Map(request["payloads"] as object[]), ShapeMapper.Map(request["queryString"] as IDictionary <string, object>)));
        }
예제 #3
0
        private static Response Map(IDictionary <string, object> response)
        {
            if (response == null)
            {
                return(null);
            }

            return(new Response(response["name"] as string, response["description"] as string, response["statusCode"] as string,
                                ParameterMapper.Map(response["headers"] as object[]), PayloadMapper.Map(response["payloads"] as object[]),
                                ExampleMapper.Map(response["examples"] as object[])));
        }
예제 #4
0
        internal static SecurityScheme Map(IDictionary <string, object> security)
        {
            if (security == null)
            {
                return(null);
            }

            return(new SecurityScheme(security["name"] as string, security["type"] as string, security["displayName"] as string,
                                      security["description"] as string, ParameterMapper.Map(security["headers"] as object[]),
                                      ParameterMapper.Map(security["queryParameters"] as object[]),
                                      ResponseMapper.Map(security["responses"] as object[]), SettingsMapper.Map(security["settings"] as IDictionary <string, object>),
                                      ShapeMapper.Map(security["queryString"] as IDictionary <string, object>)));
        }
예제 #5
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[])));
        }