Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions samples/databases/wide-world-importers/wwi-app/wwi-app.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<!-- PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback -->
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>hrkljush.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Areas\**" />
<Compile Remove="SqlServerRestApi\**" />
<Compile Remove="wwwroot\public\**" />
<Content Remove="Areas\**" />
<Content Remove="SqlServerRestApi\**" />
<Content Remove="wwwroot\public\**" />
<EmbeddedResource Remove="Areas\**" />
<EmbeddedResource Remove="SqlServerRestApi\**" />
<EmbeddedResource Remove="wwwroot\public\**" />
<None Remove="Areas\**" />
<None Remove="SqlServerRestApi\**" />
<None Remove="wwwroot\public\**" />
</ItemGroup>
<ItemGroup>
Expand Down
101 changes: 101 additions & 0 deletions samples/databases/wide-world-importers/wwi-app/wwwroot/OData.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<#@ output extension=".yaml"#>
<#@ assembly name="Newtonsoft.Json" #>
<#@ template language="C#" hostspecific="True" #>
<#
var o = Newtonsoft.Json.Linq.JObject.Parse(System.IO.File.ReadAllText(this.Host.ResolvePath("..") + "\\appsettings.json"));
var json = o["ApiModel"].ToString();
TableDef[] config = Newtonsoft.Json.JsonConvert.DeserializeObject<TableDef[]>(json);
#>
swagger: "2.0"
info:
description: "OData service exposing information from WideWorldImporters database."
version: "1.0.0"
title: "Wide World Importers"
termsOfService: "http://swagger.io/terms/"
contact:
email: "sqlserversamples@microsoft.com"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "localhost:64958"
basePath: "/OData"
tags:
<# foreach(var t in config) {#>
<# if(string.IsNullOrEmpty(t.ODataColumns)) continue; #>
- name: "<#= t.Table #>"
description: "Information about <#= t.Table #>"
<# } #>
schemes:
- "https"
- "http"
paths:
<# foreach(var t in config) {#>
<# if(string.IsNullOrEmpty(t.ODataColumns)) continue; #>

/<#= t.Table #>:
get:
tags:
- "<#= t.Table #>"
summary: "Find information about <#= t.Table #>"
description: "Multiple status values can be provided with comma separated strings"
operationId: "<#= t.Table #>"
produces:
- "application/json"
parameters:
- name: "$select"
in: "query"
description: "Selecting the properties that should be returned by service"
required: false
type: "array"
items:
type: "string"
enum:<# foreach(var c in t.ODataColumns.Split(',')) {#>
- "<#= c #>"<# } #>
collectionFormat: "multi"
- name: "$orderby"
in: "query"
description: "Ordering results by properties"
required: false
type: "array"
items:
type: "string"
enum:<# foreach(var c in t.ODataColumns.Split(',')) {#>
- "<#= c #>"
- "<#= c #> asc"
- "<#= c #> desc"<# } #>
collectionFormat: "multi"
- name: "$top"
in: "query"
description: "Selecting the properties that should be returned by service"
required: false
type: "integer"
- name: "$skip"
in: "query"
description: "Selecting the properties that should be returned by service"
required: false
type: "integer"
- name: "$apply"
in: "query"
description: "aggregation function that should be applied on the results"
required: false
type: "string"
- name: "$filter"
in: "query"
description: "Condition that returned items must satisfy"
required: false
type: "string"
responses:
200:
description: "Provided information about <#= t.Table #>."
400:
description: "The OData request is not valid"
500:
description: "Cannot process request"<# } #>
<#+
public class TableDef {
public string Schema {get; set;}
public string Table {get; set;}
public string ODataColumns {get; set;}
public bool IsReadOnly {get; set;}
}
#>
Loading