Skip to content

Commit 57b24a3

Browse files
authored
Merge pull request #841 from microsoftgraph/feat/tsp-fixes
feat/tsp fixes
2 parents e1ba6d9 + 82b9b4f commit 57b24a3

10 files changed

Lines changed: 3817 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ updates:
55
schedule:
66
interval: daily
77
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: npm
10+
directory: "/additions"
11+
schedule:
12+
interval: daily
13+
open-pull-requests-limit: 10
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: validate typespec changes
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: additions
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup NodeJs
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '22.x'
22+
23+
- name: Install typescript and typespec globally
24+
run: npm i -g typescript @typespec/compiler
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: build typespec
30+
run: tsp compile .
31+
32+
- uses: actions/upload-artifact@v4
33+
if: always()
34+
with:
35+
name: CSDLs
36+
path: tsp-output/*.csdl

additions/.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/

additions/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# TypeSpec annotations additions
2+
3+
This TypeSpec project allows you to define additional annotations to inject in the CSDL files. It's an alternative to the XLST in `/transform`.
4+
The copy scripts (in `/scripts/copy-annotations-to-csdl.ps1`) ONLY considers annotations, and DOES NOT perform any deduplication other than the ones enforced by XML keys.
5+
6+
## Requirements
7+
8+
- Node 22.x or above
9+
- TypeScript `npm i -g typescript`
10+
- TypeSpec compiler `npm i -g @typespec/compiler`
11+
- dependencies installed `npm ci`
12+
- vscode (or equivalent) `sudo winget install Microsoft.VisualStudioCode`
13+
14+
## Getting started
15+
16+
1. Make changes to the TypeSpec (.tsp) file
17+
1. Run the compilation `tsp compile . --watch`
18+
1. Run the copy scripts `.\scripts\copy-annotations-to-csdl.ps1 -sourceCsdlDirectoryPath $pwd\additions\tsp-output -targetCsdlPath $pwd\clean_v10_metadata\cleanMetadataWithDescriptionsAndAnnotationsAndErrorsv1.0.xml`
19+
1. Diff the changes to ensure this is what you expect
20+
21+
> Note: Do not commit any changes to the target CSDL as those are generated weekly.

additions/main.tsp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import "@microsoft/typespec-msgraph";
2+
3+
using MsGraph;
4+
5+
@publicNamespace("microsoft.graph")
6+
@container("GraphService")
7+
namespace microsoft.graph {
8+
9+
@entity()
10+
model OrgContact extends SharedModels.entity {
11+
displayName: string | null
12+
}
13+
@graphRoute("contacts/{id}")
14+
interface OrgContactsById extends Resource<OrgContact> {
15+
@select GetResource is GraphOps.GetResource;
16+
}
17+
@graphRoute("contacts")
18+
interface OrgContacts extends Collection<OrgContact> {
19+
@orderBy("displayName") @filter("*") @search @count @select @top GetCollection is GraphOps.GetPagedCollection;
20+
}
21+
}

0 commit comments

Comments
 (0)