Skip to content

Commit ae4fd06

Browse files
Addressing Jason's comments
1 parent 9f78fe9 commit ae4fd06

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/swagger-generation/src/swaggerWriter.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,31 @@ export const writeSwagger = (definitionMap: DefinitionMap, config: Config): Swag
9393
if (!entityTypeConfig.RootUri) { // Entity is not exposed
9494
return;
9595
}
96+
97+
// Skip internal entities
98+
if (entityTypeConfig.IsInternal) {
99+
return;
100+
}
101+
96102
const entityName: string = definitionMap.EntityMap.get(id)!.Name
97103
const entitySegments: string[] = entityTypeConfig.RootUri.split("/").slice(-2)
98104
const operationType: string = entityTypeConfig.IsReadonlyResource ? "get" : "put";
99105
const operationDescription: string = entityTypeConfig.IsReadonlyResource ? "Get" : "Create or update";
100106
const parentEntity: string = entitySegments[0];
101107
const entitySet: string = entitySegments[1];
102108
let relativeUri: string = entitySet;
103-
let parameters: Parameter[] = [
104-
{
109+
let parameters: Parameter[] = [];
110+
111+
// For singleton resources, don't add ID parameter
112+
if (!entityTypeConfig.IsSingleton) {
113+
parameters.push({
105114
in: "path",
106115
description: `The id of the ${entityName}`,
107116
name: `${entityName}Id`,
108117
required: true,
109118
type: "string"
110-
},
111-
];
119+
});
120+
}
112121

113122
if (!entityTypeConfig.IsReadonlyResource) {
114123
parameters.push(
@@ -135,7 +144,9 @@ export const writeSwagger = (definitionMap: DefinitionMap, config: Config): Swag
135144
})
136145
};
137146

138-
const host: string = `/{rootScope}/providers/Microsoft.Graph/${relativeUri}/{${entityName}Id}`
147+
// For singleton resources, don't include the ID in the path
148+
const pathIdSegment = entityTypeConfig.IsSingleton ? "" : `/{${entityName}Id}`;
149+
const host: string = `/{rootScope}/providers/Microsoft.Graph/${relativeUri}${pathIdSegment}`
139150
const path: Path = {
140151
[operationType]: {
141152
tags: [

0 commit comments

Comments
 (0)