Skip to content

Commit

Permalink
fix for some types
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Oct 16, 2024
1 parent c1b323d commit 2f1c43f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class OasSchemaHelper {
.replace("DTO", "")
.replace(this.schemaRefPrefix, "")
.replace(
/(?<!(AdminProduct|CreateProduct|StoreShippingOption|AdminShippingOption))Type$/,
/(?<!(AdminProduct|CreateProduct|StoreShippingOption|AdminShippingOption|CreateShippingOption))Type$/,
""
)
}
Expand Down
45 changes: 43 additions & 2 deletions www/utils/packages/docs-generator/src/classes/kinds/oas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2055,8 +2055,49 @@ class OasKindGenerator extends FunctionKindGenerator {
!Object.hasOwn(oldSchemaObj!.properties!, propertyKey)
)
.forEach((newPropertyKey) => {
oldSchemaObj!.properties![newPropertyKey] =
newSchemaObj!.properties![newPropertyKey]
const tryToUpdateSchema = (
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
) => {
let updatedSchema = schema
const newPropertySchemaName = this.oasSchemaHelper.isRefObject(
schema
)
? schema.$ref
: "x-schemaName" in schema
? (schema["x-schemaName"] as string)
: undefined
if (newPropertySchemaName) {
const schemaToUpdate = this.oasSchemaHelper.getSchemaByName(
newPropertySchemaName,
true,
true
)

if (schemaToUpdate) {
updatedSchema =
this.updateSchema({
oldSchema: schemaToUpdate.schema,
newSchema: schema,
level: maybeIncrementLevel(level, "object"),
}) || newProperty
}
}

return updatedSchema
}

let newProperty = newSchemaObj!.properties![newPropertyKey]

if (
!this.oasSchemaHelper.isRefObject(newProperty) &&
newProperty.type === "array"
) {
newProperty.items = tryToUpdateSchema(newProperty.items)
} else {
newProperty = tryToUpdateSchema(newProperty)
}

oldSchemaObj!.properties![newPropertyKey] = newProperty
})
}
} else if (
Expand Down

0 comments on commit 2f1c43f

Please sign in to comment.