1+ <#@ output extension=".yaml"#>
2+ <#@ assembly name="Newtonsoft.Json" #>
3+ <#@ template language="C#" hostspecific="True" #>
4+ <#
5+ var o = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(this.Host.ResolvePath("..") + "\\appsettings.json"));
6+ var json = o["ApiModel"].ToString();
7+ TableDef[] config = Newtonsoft.Json.JsonConvert.DeserializeObject<TableDef[]>(json);
8+ #>
9+ swagger: "2.0"
10+ info:
11+ description: "OData service exposing information from WideWorldImporters database."
12+ version: "1.0.0"
13+ title: "Wide World Importers"
14+ termsOfService: "http://swagger.io/terms/"
15+ contact:
16+ email: "sqlserversamples@microsoft.com"
17+ license:
18+ name: "Apache 2.0"
19+ url: "http://www.apache.org/licenses/LICENSE-2.0.html"
20+ host: "localhost:64958"
21+ basePath: "/OData"
22+ tags:
23+ <# foreach(var t in config) {#>
24+ <# if(string.IsNullOrEmpty(t.ODataColumns)) continue; #>
25+ - name: "<#= t.Table #>"
26+ description: "Information about <#= t.Table #>"
27+ <# } #>
28+ schemes:
29+ - "https"
30+ - "http"
31+ paths:
32+ <# foreach(var t in config) {#>
33+ <# if(string.IsNullOrEmpty(t.ODataColumns)) continue; #>
34+
35+ /<#= t.Table #>:
36+ get:
37+ tags:
38+ - "<#= t.Table #>"
39+ summary: "Find information about <#= t.Table #>"
40+ description: "Multiple status values can be provided with comma separated strings"
41+ operationId: "<#= t.Table #>"
42+ produces:
43+ - "application/json"
44+ parameters:
45+ - name: "$select"
46+ in: "query"
47+ description: "Selecting the properties that should be returned by service"
48+ required: false
49+ type: "array"
50+ items:
51+ type: "string"
52+ enum:<# foreach(var c in t.ODataColumns.Split(',')) {#>
53+ - "<#= c #>"<# } #>
54+ collectionFormat: "multi"
55+ - name: "$orderby"
56+ in: "query"
57+ description: "Ordering results by properties"
58+ required: false
59+ type: "array"
60+ items:
61+ type: "string"
62+ enum:<# foreach(var c in t.ODataColumns.Split(',')) {#>
63+ - "<#= c #>"
64+ - "<#= c #> asc"
65+ - "<#= c #> desc"<# } #>
66+ collectionFormat: "multi"
67+ - name: "$top"
68+ in: "query"
69+ description: "Selecting the properties that should be returned by service"
70+ required: false
71+ type: "integer"
72+ - name: "$skip"
73+ in: "query"
74+ description: "Selecting the properties that should be returned by service"
75+ required: false
76+ type: "integer"
77+ - name: "$apply"
78+ in: "query"
79+ description: "aggregation function that should be applied on the results"
80+ required: false
81+ type: "string"
82+ - name: "$filter"
83+ in: "query"
84+ description: "Condition that returned items must satisfy"
85+ required: false
86+ type: "string"
87+ responses:
88+ 200:
89+ description: "Provided information about <#= t.Table #>."
90+ 400:
91+ description: "The OData request is not valid"
92+ 500:
93+ description: "Cannot process request"<# } #>
94+ <#+
95+ public class TableDef {
96+ public string Schema {get; set;}
97+ public string Table {get; set;}
98+ public string ODataColumns {get; set;}
99+ public bool IsReadOnly {get; set;}
100+ }
101+ #>
0 commit comments