Skip to content

Commit

Permalink
Refactor (openapi_parser): update getBodySchemaName function to retur…
Browse files Browse the repository at this point in the history
…n the appropriate schema due to pydantic v2 upgrade
  • Loading branch information
aybruhm committed May 25, 2024
1 parent f573878 commit 754ead3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion agenta-web/src/lib/helpers/openapi_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {GenericObject, Parameter} from "../Types"

const getBodySchemaName = (schema: GenericObject): string => {
return (
schema?.paths?.["/generate"]?.post?.requestBody?.content["application/json"]?.schema["$ref"]
schema?.paths?.["/generate"]?.post?.requestBody?.content?.["application/json"]?.schema?.[
"allOf"
]?.[0]?.["$ref"]
?.split("/")
?.pop() || ""
)
Expand All @@ -20,6 +22,7 @@ export const detectChatVariantFromOpenAISchema = (schema: GenericObject) => {
export const openAISchemaToParameters = (schema: GenericObject): Parameter[] => {
const parameters: Parameter[] = []
const bodySchemaName = getBodySchemaName(schema)
console.log("Body Schema Name: ", bodySchemaName)

// get the actual schema for the body parameters
Object.entries(schema.components.schemas[bodySchemaName].properties || {}).forEach(
Expand Down

0 comments on commit 754ead3

Please sign in to comment.