/// <summary>
        /// Create a <see cref="OpenApiDocument"/>, it's a single Open API Object.
        /// </summary>
        /// <param name="context">The OData to Open API context.</param>
        /// <returns>The created <see cref="OpenApiDocument"/> object.</returns>
        public static OpenApiDocument CreateDocument(this ODataContext context)
        {
            Utils.CheckArgumentNull(context, nameof(context));

            // An OAS document consists of a single OpenAPI Object represented as OpenApiDocument object.
            // {
            //   "openapi":"3.0.0",
            //   "info": …,
            //   "servers": …,
            //   "tags": …,
            //   "paths": …,
            //   "components": …
            // }
            OpenApiDocument doc = new OpenApiDocument
            {
                Info = context.CreateInfo(),

                Servers = context.CreateServers(),

                //   Tags = context.CreateTags(),

                Paths = context.CreatePaths(),

                Components = context.CreateComponents(),

                SecurityRequirements = null,

                ExternalDocs = null
            };

            doc.Tags = context.CreateTags();

            return(doc);
        }
Esempio n. 2
0
        public void CreateComponentsThrowArgumentNullContext()
        {
            // Arrange
            ODataContext context = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>("context", () => context.CreateComponents());
        }
Esempio n. 3
0
        public void CreateComponentsReturnsForEmptyModel()
        {
            // Arrange
            IEdmModel    model   = EdmModelHelper.EmptyModel;
            ODataContext context = new ODataContext(model);

            // Act
            var components = context.CreateComponents();

            // Assert
            Assert.NotNull(components);
            Assert.NotNull(components.Schemas);
            Assert.NotNull(components.Parameters);
            Assert.NotNull(components.Responses);
            Assert.NotNull(components.RequestBodies);
        }