Skip to content

Commit 72799cd

Browse files
committed
Initial commit of typespec
1 parent d04ef65 commit 72799cd

22 files changed

+2148
-0
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Build'
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths-ignore:
9+
- 'docs/openapi.json'
10+
pull_request:
11+
branches:
12+
- main
13+
14+
jobs:
15+
build:
16+
runs-on: windows-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Compile TypeSpec
21+
run: tsp compile src/main.tsp --emit @typespec/openapi3
22+
- name: Fix OpenAPI
23+
run: ./fixOpenApi.ps1
24+
shell: pwsh
25+
- name: Update docs
26+
uses: test-room-7/action-update-file@v2.0.0

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# MacOS
2+
.DS_Store
3+
4+
# Default TypeSpec output
5+
tsp-output/
6+
dist/
7+
8+
# Dependency directories
9+
node_modules/

.vscode/tasks.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Build SharePointAPI client",
6+
"detail": "Generate OpenAPI, run Kiota and compile the client",
7+
"type": "shell",
8+
"command": "./build-client.ps1",
9+
"presentation": {
10+
"echo": true,
11+
"reveal": "always",
12+
"focus": false,
13+
"panel": "shared",
14+
"showReuseMessage": true,
15+
"clear": false
16+
},
17+
"problemMatcher": []
18+
},
19+
{
20+
"type": "typespec",
21+
"path": "d:/Repos/pschaeflein/graph-community-metadata/src/main.tsp",
22+
"args": "--watch",
23+
"problemMatcher": {
24+
"owner": "tsp",
25+
"fileLocation": "absolute",
26+
"source": "typespec",
27+
"pattern": {
28+
"regexp": "^..\\/(.*.tsp):(\\d+):(\\d+) - (warning|error) (.*)$",
29+
"file": 1,
30+
"line": 2,
31+
"column": 3,
32+
"severity": 4,
33+
"message": 5
34+
},
35+
"background": {
36+
"activeOnStart": true,
37+
}
38+
},
39+
"runOptions": {
40+
"runOn": "folderOpen"
41+
},
42+
"isBackground": true,
43+
"label": "tsp: watch - main.tsp"
44+
}
45+
]
46+
}

fixOpenApi.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$openApiFile = "./dist/@typespec/openapi3/openapi.json"
2+
$docsApiFile = "./docs/openapi.json"
3+
# read output from typespec
4+
$json = Get-Content -Raw -Path $openApiFile | ConvertFrom-Json
5+
# update the info object
6+
$info = $json.info
7+
$xLogo = @{
8+
url = "https://pschaeflein.github.io/graph-community-metadata/graph-community-spclient.png"
9+
backgroundColor = "#FFFFFF"
10+
altText = "Graph.Community SDK for Microsoft SharePoint REST API"
11+
}
12+
if (Get-Member -InputObject $info -Name "x-logo" -MemberType Properties) {}
13+
else { Add-Member -InputObject $info -MemberType NoteProperty -Name "x-logo" -Value $xLogo }
14+
# update the discriminator mapping
15+
$mapping = $json.components.schemas.Principal.discriminator.mapping
16+
if (Get-Member -InputObject $mapping -Name "#SP.Group" -MemberType Properties) {}
17+
else { Add-Member -InputObject $mapping -MemberType NoteProperty -Name "#SP.Group" -Value "#/components/schemas/Group" }
18+
if (Get-Member -InputObject $mapping -Name "#SP.User" -MemberType Properties) {}
19+
else { Add-Member -InputObject $mapping -MemberType NoteProperty -Name "#SP.User" -Value "#/components/schemas/User" }
20+
#write docs file
21+
$json | ConvertTo-Json -Depth 100 | Set-Content -Path $docsApiFile

0 commit comments

Comments
 (0)