Skip to content

Commit

Permalink
Introduce CodegenSchemaPurpose.PARENT to better describe why the pare…
Browse files Browse the repository at this point in the history
…nt schema is created
  • Loading branch information
karlvr committed Sep 9, 2024
1 parent 4474205 commit 778ef0c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/happy-needles-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@openapi-generator-plus/types": minor
"@openapi-generator-plus/core": minor
---

Introduce CodegenSchemaPurpose.PARENT to better describe why the parent schema is created
2 changes: 1 addition & 1 deletion packages/core/src/process/schema/all-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function toCodegenAllOfSchemaObject(apiSchema: OpenAPIX.SchemaObject, naming: Sc
const parentSchema = toCodegenSchemaUsage(allOfApiSchema, state, {
required: true,
suggestedName: `${result.name}_parent`,
purpose: CodegenSchemaPurpose.ALL_OF,
purpose: CodegenSchemaPurpose.PARENT,
suggestedScope: scope,
}).schema

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/process/schema/any-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function toCodegenAnyOfSchemaObject(apiSchema: OpenAPIX.SchemaObject, naming: Sc
const anyOfSchema = toCodegenSchemaUsage(anyOfApiSchema, state, {
required: true,
suggestedName: `${result.name}_submodel`,
purpose: CodegenSchemaPurpose.ANY_OF,
purpose: CodegenSchemaPurpose.ABSORB,
suggestedScope: result,
}).schema
if (!isCodegenObjectSchema(anyOfSchema)) {
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,10 @@ export enum CodegenSchemaPurpose {
* The schema is being created for the purposes of being absorbed into another schema as part of inheritance / hierarchy.
*/
ABSORB = 'ABSORB',
/**
* The schema is a parent of another schema (such as an allOf)
*/
PARENT = 'PARENT',
}

export interface CodegenNativeTypeOptions extends CodegenTypeOptions {
Expand Down

0 comments on commit 778ef0c

Please sign in to comment.