@@ -23,7 +23,10 @@ import {
2323import { HttpService , getAllHttpServices , reportIfNoRoutes , getHttpOperation , HttpOperation } from "@typespec/http" ;
2424// import { SdkContext, createSdkContext } from "@azure-tools/typespec-client-generator-core";
2525import { getResourcePath , swaggerResourcePathToResourceId , } from "./utils.js" ;
26- import { AAZResourceEmitterSchema , AAZTspPathItem , MutabilityEnum , AAZTspHttpOperation } from "./types.js" ;
26+ import { AAZResourceEmitterSchema } from "./types.js" ;
27+ import { TypeSpecPathItem } from "./model/path_item.js"
28+ import { MutabilityEnum } from "./model/_fields.js"
29+ import { CMDHttpOperation } from "./model/operation.js"
2730import { AAZEmitterOptions , getTracer } from "./lib.js" ;
2831
2932export async function $onEmit ( context : EmitContext < AAZEmitterOptions > ) {
@@ -34,14 +37,9 @@ export async function $onEmit(context: EmitContext<AAZEmitterOptions>) {
3437 path : resolvePath ( context . emitterOutputDir , "resources.json" ) ,
3538 content : JSON . stringify ( resources , null , 2 ) ,
3639 } ) ;
37- } else if ( context . options . operation === "retrieve-operation" ) {
38- // TODO:
39- // const sdkContext = createSdkContext(context, "@client-tools/typespec-aaz");
40- // const emitter = createRetrieveOperationsEmitter(sdkContext);
41- // await emitter.retrieveOperations();
4240 } else if ( context . options . operation === "get-resources-operations" ) {
4341 const emitter = createGetResourceOperationEmitter ( context ) ;
44- const res = await emitter . getResourcesOperation ( ) ;
42+ const res = await emitter . getResourcesOperations ( ) ;
4543 await emitFile ( context . program , {
4644 path : resolvePath ( context . emitterOutputDir , "resources_operations.json" ) ,
4745 content : JSON . stringify ( res , null , 2 ) ,
@@ -123,9 +121,9 @@ function createGetResourceOperationEmitter(context: EmitContext<AAZEmitterOption
123121 version : context . options . apiVersion ,
124122 }
125123 } ) || [ ] ;
126- let schema : AAZTspPathItem = { } ;
124+ let schema : TypeSpecPathItem = { } ;
127125
128- async function getResourcesOperation ( ) {
126+ async function getResourcesOperations ( ) {
129127 tracer . trace ( "options for createGetResourceOperationEmitter" , JSON . stringify ( context . options , null , 2 ) ) ;
130128 const services = listServices ( context . program ) ;
131129 for ( const service of services ) {
@@ -149,7 +147,7 @@ function createGetResourceOperationEmitter(context: EmitContext<AAZEmitterOption
149147 return result ;
150148 }
151149
152- return { getResourcesOperation } ;
150+ return { getResourcesOperations } ;
153151
154152 function emitResourcesOperations ( program : Program , operations : HttpOperation [ ] ) {
155153 for ( let rt of result ) {
@@ -167,7 +165,7 @@ function createGetResourceOperationEmitter(context: EmitContext<AAZEmitterOption
167165 }
168166 }
169167
170- function emitResourceOperation ( program : Program , httpOperation : HttpOperation , resourceObj : AAZResourceEmitterSchema , schema :AAZTspPathItem ) {
168+ function emitResourceOperation ( program : Program , httpOperation : HttpOperation , resourceObj : AAZResourceEmitterSchema , schema :TypeSpecPathItem ) {
171169 let { path : fullPath , operation : op , verb, parameters } = httpOperation ;
172170 let selected_path = getPathWithoutArg ( fullPath ) . toLocaleLowerCase ( ) ;
173171 if ( selected_path != resourceObj . id ) {
@@ -193,7 +191,7 @@ function createGetResourceOperationEmitter(context: EmitContext<AAZEmitterOption
193191 } else {
194192 console . log ( " verb not expected: " , verb )
195193 }
196- let operationOnMutability : AAZTspHttpOperation ;
194+ let operationOnMutability : CMDHttpOperation ;
197195 for ( let mut of mutability ) {
198196 operationOnMutability = {
199197 operationId : opId ,
@@ -244,7 +242,7 @@ function createGetResourceOperationEmitter(context: EmitContext<AAZEmitterOption
244242 return false ;
245243 }
246244
247- function populateOperationOnMutability ( program : Program , httpOperation : HttpOperation , operationOnMutability :AAZTspHttpOperation ) {
245+ function populateOperationOnMutability ( program : Program , httpOperation : HttpOperation , operationOnMutability : CMDHttpOperation ) {
248246 operationOnMutability . description = getDoc ( program , httpOperation . operation ) ;
249247
250248 const lroMetadata = getLroMetadata ( program , httpOperation . operation ) ;
@@ -260,8 +258,6 @@ function createGetResourceOperationEmitter(context: EmitContext<AAZEmitterOption
260258 request : { } as any ,
261259 response : [ ] ,
262260 }
263-
264-
265261 }
266262
267263}
0 commit comments