Example #1
0
        /// <summary>
        /// Initialize the entity container to Swagger model.
        /// </summary>
        protected virtual void InitializeContainer()
        {
            Contract.Assert(SwaggerDoc != null);
            Contract.Assert(EdmModel != null);

            SwaggerPaths = new JObject();
            SwaggerDoc.Add("paths", SwaggerPaths);

            if (EdmModel.EntityContainer == null)
            {
                return;
            }

            foreach (var entitySet in EdmModel.EntityContainer.EntitySets())
            {
                SwaggerPaths.Add("/" + entitySet.Name, ODataSwaggerUtilities.CreateSwaggerPathForEntitySet(entitySet));

                SwaggerPaths.Add(ODataSwaggerUtilities.GetPathForEntity(entitySet),
                                 ODataSwaggerUtilities.CreateSwaggerPathForEntity(entitySet));
            }

            foreach (var operationImport in EdmModel.EntityContainer.OperationImports())
            {
                SwaggerPaths.Add(ODataSwaggerUtilities.GetPathForOperationImport(operationImport),
                                 ODataSwaggerUtilities.CreateSwaggerPathForOperationImport(operationImport));
            }
        }
Example #2
0
        public void GetPathForOperationImport_Returns()
        {
            // Arrange & Act
            string path = ODataSwaggerUtilities.GetPathForOperationImport(_getCustomers);

            // Assert
            Assert.NotNull(path);
            Assert.Equal("/GetCustomers()", path);
        }