Skip to content

Commit 70a8e03

Browse files
committed
add basic auth
1 parent 238f8b6 commit 70a8e03

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

typespec/lib.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const $lib = createTypeSpecLibrary({
2+
// ...
3+
state: {
4+
customName: { description: "State for the @customName decorator" },
5+
},
6+
});
7+
8+
export const StateKeys = $lib.stateKeys;

typespec/model.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// import { StateKeys } from "./lib.js";
2+
3+
// // Create a unique key
4+
// const key = StateKeys.customName;
5+
// export function $faker(context, target, name) {
6+
// // Keep a mapping between the target and a value.
7+
// context.program.stateMap(key).set(target, name);
8+
9+
// // Keep an index of a type.
10+
// context.program.stateSet(key).add(target);
11+
// }
12+
let key = 0;
13+
export function $faker(context, target, name) {
14+
console.log(target.node)
15+
// if (target.model) {
16+
// console.log(name);
17+
// // console.log(context);
18+
// console.log(target.model.properties);
19+
// // context.program.stateMap(key).set(target, name);
20+
// // key += 1;
21+
22+
// target.type['x-faker'] = name.value;
23+
// console.log('---------------------');
24+
// }
25+
}

typespec/postman/services/tasksService.tsp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,22 @@ interface TaskService {
1818
@query select?: string[]
1919
): Tasks;
2020

21+
@useAuth(BasicAuth)
2122
@get
2223
op get(
2324
@path id: string,
2425
@query select?: string
2526
): Task;
2627

28+
@useAuth(BasicAuth)
2729
@post
2830
op create(...NewTaskDto): Task;
2931

32+
@useAuth(BasicAuth)
3033
@patch
3134
op update(@path id: string, ...EditTaskDto): Task;
3235

36+
@useAuth(BasicAuth)
3337
@delete
3438
op delete(@path id: string): void;
3539
}

0 commit comments

Comments
 (0)