From 70a8e0305b44c3c959fe76d2a8ab02a6d7171a89 Mon Sep 17 00:00:00 2001 From: Ivan Gagarinov Date: Thu, 14 Nov 2024 11:59:28 +0500 Subject: [PATCH] add basic auth --- typespec/lib.js | 8 +++++++ typespec/model.js | 25 ++++++++++++++++++++++ typespec/postman/services/tasksService.tsp | 4 ++++ 3 files changed, 37 insertions(+) create mode 100644 typespec/lib.js create mode 100644 typespec/model.js diff --git a/typespec/lib.js b/typespec/lib.js new file mode 100644 index 0000000..915be6a --- /dev/null +++ b/typespec/lib.js @@ -0,0 +1,8 @@ +export const $lib = createTypeSpecLibrary({ + // ... + state: { + customName: { description: "State for the @customName decorator" }, + }, +}); + +export const StateKeys = $lib.stateKeys; diff --git a/typespec/model.js b/typespec/model.js new file mode 100644 index 0000000..4387394 --- /dev/null +++ b/typespec/model.js @@ -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('---------------------'); + // } +} diff --git a/typespec/postman/services/tasksService.tsp b/typespec/postman/services/tasksService.tsp index 77f3888..36b6ee7 100644 --- a/typespec/postman/services/tasksService.tsp +++ b/typespec/postman/services/tasksService.tsp @@ -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; }