/// <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> /// 读取. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReadDoc_Click(object sender, EventArgs e) { swaggerDoc = SwaggerDocReader.GetSwaggerDoc(this.txtSwaggerDocUrl.Text); btnCreateMyJavaScriptService.Enabled = true; }
private void AddSwaggerDoc(SwaggerGenOptions options) { while (versions.TryTake(out string v)) { SwaggerDoc doc = SwaggerDoc.Factory.Create(Configuration, v); options.SwaggerDoc(doc); } }
/// <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)); } }
public static SwaggerDoc GetSwaggerDoc(string url) { using (WebClient client = new WebClient()) { client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); using (Stream s = client.OpenRead(url)) { using (StreamReader sr = new StreamReader(s, Encoding.UTF8)) { string resultText = sr.ReadToEnd(); resultText = resultText.Replace("$ref", "ref"); SwaggerDoc resultData = JsonConvert.DeserializeObject <SwaggerDoc>(resultText); return(resultData); } } } }
public MyJavaScriptService(SwaggerDoc swaggerDoc) { this.DocInfo = swaggerDoc; }
public static void SwaggerDoc(this SwaggerGenOptions options, SwaggerDoc doc) { options.SwaggerDoc(doc.Version, doc); }