/// <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)); } }
/// <summary> /// Initialize the type definitions to Swagger model. /// </summary> protected virtual void InitializeTypeDefinitions() { Contract.Assert(SwaggerDoc != null); Contract.Assert(EdmModel != null); SwaggerDefinitions = new JObject(); SwaggerDoc.Add("definitions", SwaggerDefinitions); foreach (var type in EdmModel.SchemaElements.OfType <IEdmStructuredType>()) { SwaggerDefinitions.Add(type.FullTypeName(), ODataSwaggerUtilities.CreateSwaggerDefinitionForStructureType(type)); } }