Skip to content

Commit

Permalink
add basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dzencot committed Nov 14, 2024
1 parent 238f8b6 commit 70a8e03
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions typespec/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const $lib = createTypeSpecLibrary({
// ...
state: {
customName: { description: "State for the @customName decorator" },
},
});

export const StateKeys = $lib.stateKeys;
25 changes: 25 additions & 0 deletions typespec/model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// import { StateKeys } from "./lib.js";

// // Create a unique key
// const key = StateKeys.customName;
// export function $faker(context, target, name) {
// // Keep a mapping between the target and a value.
// context.program.stateMap(key).set(target, name);

// // Keep an index of a type.
// context.program.stateSet(key).add(target);
// }
let key = 0;
export function $faker(context, target, name) {
console.log(target.node)
// if (target.model) {
// console.log(name);
// // console.log(context);
// console.log(target.model.properties);
// // context.program.stateMap(key).set(target, name);
// // key += 1;

// target.type['x-faker'] = name.value;
// console.log('---------------------');
// }
}
4 changes: 4 additions & 0 deletions typespec/postman/services/tasksService.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ interface TaskService {
@query select?: string[]
): Tasks;

@useAuth(BasicAuth)
@get
op get(
@path id: string,
@query select?: string
): Task;

@useAuth(BasicAuth)
@post
op create(...NewTaskDto): Task;

@useAuth(BasicAuth)
@patch
op update(@path id: string, ...EditTaskDto): Task;

@useAuth(BasicAuth)
@delete
op delete(@path id: string): void;
}

0 comments on commit 70a8e03

Please sign in to comment.