Skip to content

Commit db6e656

Browse files
committed
Update naming logic.
1 parent ff40416 commit db6e656

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

packages/openapi3/src/openapi.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,44 @@ function createOAPIEmitter(
13101310
const declarations = files[0].globalScope.declarations;
13111311
for (const declaration of declarations) {
13121312
schemas[declaration.name] = declaration.value as any;
1313-
}
1313+
// TODO: THe old logic
1314+
// // Emit the processed schemas. Only now can we compute the names as it
1315+
// // depends on whether we have produced multiple schemas for a single
1316+
// // TYPESPEC type.
1317+
// for (const group of processedSchemas.values()) {
1318+
// for (const [visibility, processed] of group) {
1319+
// let name = getOpenAPITypeName(program, processed.type, typeNameOptions);
1320+
// if (group.size > 1) {
1321+
// const suffix = getVisibilitySuffix(visibility, Visibility.All);
1322+
// // ignore plain "Read" suffix since it is the canonical visibility
1323+
// // for referenced schemas
1324+
// if (suffix !== "Read") {
1325+
// name += suffix;
1326+
// }
1327+
// }
1328+
// checkDuplicateTypeName(program, processed.type, name, root.components!.schemas);
1329+
// processed.ref.value = "#/components/schemas/" + encodeURIComponent(name);
1330+
// if (processed.schema) {
1331+
// root.components!.schemas![name] = processed.schema;
1332+
// }
1333+
// }
1334+
// }
1335+
1336+
// function processSchemas() {
1337+
// // Process pending schemas. Note that getSchemaForType may pull in new
1338+
// // pending schemas so we iterate until there are no pending schemas
1339+
// // remaining.
1340+
// while (pendingSchemas.size > 0) {
1341+
// for (const [type, group] of pendingSchemas) {
1342+
// for (const [visibility, pending] of group) {
1343+
// processedSchemas.getOrAdd(type, visibility, () => ({
1344+
// ...pending,
1345+
// schema: getSchemaForType(type, visibility),
1346+
// }));
1347+
// }
1348+
// pendingSchemas.delete(type);
1349+
// }
1350+
// }
13141351
}
13151352

13161353
function processUnreferencedSchemas() {

packages/samples/test/output/visibility/@typespec/openapi3/openapi.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ components:
114114
relatives:
115115
type: array
116116
items:
117-
$ref: '#/components/schemas/PersonRelativeReadOrCreateOrUpdateOrDeleteOrQueryItem'
117+
$ref: '#/components/schemas/PersonRelativeItem'
118118
Person:
119119
type: object
120120
required:
@@ -176,7 +176,7 @@ components:
176176
type: array
177177
items:
178178
$ref: '#/components/schemas/PersonRelativeCreateOrUpdateItem'
179-
PersonReadOrCreateOrUpdateOrDeleteOrQueryItem:
179+
PersonItem:
180180
type: object
181181
required:
182182
- id
@@ -200,7 +200,7 @@ components:
200200
relatives:
201201
type: array
202202
items:
203-
$ref: '#/components/schemas/PersonRelativeReadOrCreateOrUpdateOrDeleteOrQueryItem'
203+
$ref: '#/components/schemas/PersonRelativeItem'
204204
PersonRelative:
205205
type: object
206206
required:
@@ -231,14 +231,14 @@ components:
231231
$ref: '#/components/schemas/PersonCreateOrUpdateItem'
232232
relationship:
233233
type: string
234-
PersonRelativeReadOrCreateOrUpdateOrDeleteOrQueryItem:
234+
PersonRelativeItem:
235235
type: object
236236
required:
237237
- person
238238
- relationship
239239
properties:
240240
person:
241-
$ref: '#/components/schemas/PersonReadOrCreateOrUpdateOrDeleteOrQueryItem'
241+
$ref: '#/components/schemas/PersonItem'
242242
relationship:
243243
type: string
244244
PersonRelativeUpdateItem:

0 commit comments

Comments
 (0)