public static SwaggerPathsFactory CreateSwaggerPathsFactory(SwaggerDocumentContext swaggerDocumentContext)
        {
            if (swaggerDocumentContext.IsProfileContext)
            {
                var profileStrategy = new SwaggerPathsFactoryProfileStrategy(swaggerDocumentContext);

                //Profile strategy implements each of the interfaces in the signature of the paths factory constructor
                //Hence the odd parameter repetition.
                return(new SwaggerPathsFactory(profileStrategy, profileStrategy, profileStrategy));
            }

            ISwaggerPathsFactorySelectorStrategy selectorStrategy       = null;
            ISwaggerPathsFactoryNamingStrategy   resourceNamingStrategy = null;

            if (swaggerDocumentContext.RenderType == RenderType.ExtensionArtifactsOnly)
            {
                selectorStrategy = new SwaggerPathsFactorySchemaSelectorStrategy(swaggerDocumentContext);
            }

            if (swaggerDocumentContext.IsCompositeContext)
            {
                selectorStrategy       = new SwaggerCompositePathsFactoryStrategy(swaggerDocumentContext);
                resourceNamingStrategy = new SwaggerPathsFactoryCompositeStrategy();
            }

            var defaultStrategy = new DefaultSwaggerPathsFactoryStrategy();
            var defaultResourceDefinitionNamingStrategy = new SwaggerPathsFactoryDefaultStrategy();

            ISwaggerPathsFactoryContentTypeStrategy contentTypeStrategy = defaultStrategy;

            selectorStrategy       = selectorStrategy ?? defaultStrategy;
            resourceNamingStrategy = resourceNamingStrategy ?? defaultResourceDefinitionNamingStrategy;

            return(new SwaggerPathsFactory(selectorStrategy, contentTypeStrategy, resourceNamingStrategy));
        }
Ejemplo n.º 2
0
 public SwaggerPathsFactory(
     ISwaggerPathsFactorySelectorStrategy swaggerPathsFactorySelectorStrategy,
     ISwaggerPathsFactoryContentTypeStrategy contentTypeStrategy,
     ISwaggerPathsFactoryNamingStrategy pathsFactoryNamingStrategy)
 {
     _swaggerPathsFactorySelectorStrategy = swaggerPathsFactorySelectorStrategy;
     _contentTypeStrategy        = contentTypeStrategy;
     _pathsFactoryNamingStrategy = pathsFactoryNamingStrategy;
 }