-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autorest emit all files programatically (#972)
Expose an API like we have in openapi3 emitter to emit all services at all version programmatically
- Loading branch information
1 parent
a8f0337
commit d179b2a
Showing
5 changed files
with
209 additions
and
71 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.chronus/changes/autorest-emitt-all-programmatically-2024-5-7-9-28-38.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@azure-tools/typespec-autorest" | ||
--- | ||
|
||
Add API to programmatically get all the OpenAPI2 documents for all services at all versions in a spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { Service, SourceFile } from "@typespec/compiler"; | ||
import type { OpenAPI2Document } from "./openapi2-document.js"; | ||
|
||
/** | ||
* A record containing the the OpenAPI 3 documents corresponding to | ||
* a particular service definition. | ||
*/ | ||
export type AutorestServiceRecord = | ||
| AutorestUnversionedServiceRecord | ||
| AutorestVersionedServiceRecord; | ||
|
||
export interface AutorestUnversionedServiceRecord extends AutorestEmitterResult { | ||
/** The service that generated this OpenAPI document */ | ||
readonly service: Service; | ||
|
||
/** Whether the service is versioned */ | ||
readonly versioned: false; | ||
} | ||
|
||
export interface AutorestVersionedServiceRecord { | ||
/** The service that generated this OpenAPI document */ | ||
readonly service: Service; | ||
|
||
/** Whether the service is versioned */ | ||
readonly versioned: true; | ||
|
||
/** The OpenAPI 3 document records for each version of this service */ | ||
readonly versions: AutorestVersionedDocumentRecord[]; | ||
} | ||
|
||
/** | ||
* A record containing an unversioned OpenAPI document and associated metadata. | ||
*/ | ||
export interface AutorestVersionedDocumentRecord extends AutorestEmitterResult { | ||
/** The service that generated this OpenAPI document. */ | ||
readonly service: Service; | ||
|
||
/** The version of the service. Absent if the service is unversioned. */ | ||
readonly version: string; | ||
} | ||
|
||
export interface OperationExamples { | ||
readonly operationId: string; | ||
readonly examples: LoadedExample[]; | ||
} | ||
|
||
export interface AutorestEmitterResult { | ||
/** The OpenAPI document*/ | ||
readonly document: OpenAPI2Document; | ||
|
||
/** The examples */ | ||
readonly operationExamples: OperationExamples[]; | ||
|
||
/** Output file used */ | ||
readonly outputFile: string; | ||
} | ||
|
||
export interface LoadedExample { | ||
readonly relativePath: string; | ||
readonly file: SourceFile; | ||
readonly data: any; | ||
} |