Skip to content

Commit

Permalink
Update naming logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Nov 16, 2023
1 parent ff40416 commit db6e656
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
39 changes: 38 additions & 1 deletion packages/openapi3/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,44 @@ function createOAPIEmitter(
const declarations = files[0].globalScope.declarations;
for (const declaration of declarations) {
schemas[declaration.name] = declaration.value as any;
}
// TODO: THe old logic
// // Emit the processed schemas. Only now can we compute the names as it
// // depends on whether we have produced multiple schemas for a single
// // TYPESPEC type.
// for (const group of processedSchemas.values()) {
// for (const [visibility, processed] of group) {
// let name = getOpenAPITypeName(program, processed.type, typeNameOptions);
// if (group.size > 1) {
// const suffix = getVisibilitySuffix(visibility, Visibility.All);
// // ignore plain "Read" suffix since it is the canonical visibility
// // for referenced schemas
// if (suffix !== "Read") {
// name += suffix;
// }
// }
// checkDuplicateTypeName(program, processed.type, name, root.components!.schemas);
// processed.ref.value = "#/components/schemas/" + encodeURIComponent(name);
// if (processed.schema) {
// root.components!.schemas![name] = processed.schema;
// }
// }
// }

// function processSchemas() {
// // Process pending schemas. Note that getSchemaForType may pull in new
// // pending schemas so we iterate until there are no pending schemas
// // remaining.
// while (pendingSchemas.size > 0) {
// for (const [type, group] of pendingSchemas) {
// for (const [visibility, pending] of group) {
// processedSchemas.getOrAdd(type, visibility, () => ({
// ...pending,
// schema: getSchemaForType(type, visibility),
// }));
// }
// pendingSchemas.delete(type);
// }
// }
}

function processUnreferencedSchemas() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ components:
relatives:
type: array
items:
$ref: '#/components/schemas/PersonRelativeReadOrCreateOrUpdateOrDeleteOrQueryItem'
$ref: '#/components/schemas/PersonRelativeItem'
Person:
type: object
required:
Expand Down Expand Up @@ -176,7 +176,7 @@ components:
type: array
items:
$ref: '#/components/schemas/PersonRelativeCreateOrUpdateItem'
PersonReadOrCreateOrUpdateOrDeleteOrQueryItem:
PersonItem:
type: object
required:
- id
Expand All @@ -200,7 +200,7 @@ components:
relatives:
type: array
items:
$ref: '#/components/schemas/PersonRelativeReadOrCreateOrUpdateOrDeleteOrQueryItem'
$ref: '#/components/schemas/PersonRelativeItem'
PersonRelative:
type: object
required:
Expand Down Expand Up @@ -231,14 +231,14 @@ components:
$ref: '#/components/schemas/PersonCreateOrUpdateItem'
relationship:
type: string
PersonRelativeReadOrCreateOrUpdateOrDeleteOrQueryItem:
PersonRelativeItem:
type: object
required:
- person
- relationship
properties:
person:
$ref: '#/components/schemas/PersonReadOrCreateOrUpdateOrDeleteOrQueryItem'
$ref: '#/components/schemas/PersonItem'
relationship:
type: string
PersonRelativeUpdateItem:
Expand Down

0 comments on commit db6e656

Please sign in to comment.