コード例 #1
0
        public void Apply_WhenEntityExists_DontAddDefinitions()
        {
            var swaggerDoc = new OpenApiDocument();

            swaggerDoc.Paths      = new OpenApiPaths();
            swaggerDoc.Components = new OpenApiComponents()
            {
                Schemas = new Dictionary <string, OpenApiSchema>()
            };
            var filter = new AutoAPISwaggerDocumentFilter();

            filter.Apply(swaggerDoc, null);

            Assert.Equal(3, swaggerDoc.Components.Schemas.Count);
            Assert.Equal("book", swaggerDoc.Components.Schemas.Keys.ToList()[1]);
        }
コード例 #2
0
        public void Apply_WhenEntity_AddPaths()
        {
            var swaggerDoc = new OpenApiDocument();

            swaggerDoc.Paths      = new OpenApiPaths();
            swaggerDoc.Components = new OpenApiComponents()
            {
                Schemas = new Dictionary <string, OpenApiSchema>()
            };
            var filter = new AutoAPISwaggerDocumentFilter();

            filter.Apply(swaggerDoc, null);

            Assert.Equal(2, APIConfiguration.AutoAPIEntityCache.Count);
            Assert.Equal(7, swaggerDoc.Paths.Count);
        }
コード例 #3
0
        public void Apply_WhenEntity_AddDefinitions()
        {
            var swaggerDoc = new OpenApiDocument();

            swaggerDoc.Paths      = new OpenApiPaths();
            swaggerDoc.Components = new OpenApiComponents()
            {
                Schemas = new Dictionary <string, OpenApiSchema>()
            };
            var filter = new AutoAPISwaggerDocumentFilter();


            filter.Apply(swaggerDoc, null);

            Assert.Equal(3, swaggerDoc.Components.Schemas.Count);
            Assert.Equal("author", swaggerDoc.Components.Schemas.First().Key);
        }