Missing `.` preceding `and` chain
prescience-data opened this issue · comments
Issue
There appears to be a missing .
when generating an and
chain.
Repro steps
Using the following spec: https://developers.pipedrive.com/docs/api/v1/openapi.json
Segment:
{
"schema": {
"title": "addDealRequest",
"allOf": [
{
"title": "requredTitleParameter",
"type": "object",
"required": [
"title"
],
"properties": {
"title": {
"type": "string",
"description": "The title of the deal"
}
}
},
{
"title": "basicDeal",
"type": "object",
"properties": {
"value": {
"type": "string",
"description": "The value of the deal. If omitted, value will be set to 0."
},
"currency": {
"type": "string",
"description": "The currency of the deal. Accepts a 3-character currency code. If omitted, currency will be set to the default currency of the authorized user."
},
"user_id": {
"type": "integer",
"description": "The ID of the user which will be the owner of the created deal. If not provided, the user making the request will be used."
},
"person_id": {
"type": "integer",
"description": "The ID of a person which this deal will be linked to. If the person does not exist yet, it needs to be created first. This property is required unless `org_id` is specified."
},
"org_id": {
"type": "integer",
"description": "The ID of an organization which this deal will be linked to. If the organization does not exist yet, it needs to be created first. This property is required unless `person_id` is specified."
},
"pipeline_id": {
"type": "integer",
"description": "The ID of the pipeline this deal will be added to. By default, the deal will be added to the first stage of the specified pipeline. Please note that `pipeline_id` and `stage_id` should not be used together as `pipeline_id` will be ignored."
},
"stage_id": {
"type": "integer",
"description": "The ID of the stage this deal will be added to. Please note that a pipeline will be assigned automatically based on the `stage_id`. If omitted, the deal will be placed in the first stage of the default pipeline."
},
"status": {
"type": "string",
"enum": [
"open",
"won",
"lost",
"deleted"
],
"description": "open = Open, won = Won, lost = Lost, deleted = Deleted. If omitted, status will be set to open."
},
"expected_close_date": {
"type": "string",
"format": "date",
"description": "The expected close date of the deal. In ISO 8601 format: YYYY-MM-DD."
},
"probability": {
"type": "number",
"description": "The success probability percentage of the deal. Used/shown only when `deal_probability` for the pipeline of the deal is enabled."
},
"lost_reason": {
"type": "string",
"description": "The optional message about why the deal was lost (to be used when status = lost)"
},
"visible_to": {
"type": "string",
"allOf": [
{
"type": "string",
"enum": [
"1",
"3",
"5",
"7"
]
}
],
"description": "The visibility of the deal. If omitted, the visibility will be set to the default visibility setting of this item type for the authorized user. Read more about visibility groups <a href=\"https://support.pipedrive.com/en/article/visibility-groups\" target=\"_blank\" rel=\"noopener noreferrer\">here</a>.<h4>Essential / Advanced plan</h4><table><tr><th style=\"width:40px\">Value</th><th>Description</th></tr><tr><td>`1`</td><td>Owner & followers</td><tr><td>`3`</td><td>Entire company</td></tr></table><h4>Professional / Enterprise plan</h4><table><tr><th style=\"width:40px\">Value</th><th>Description</th></tr><tr><td>`1`</td><td>Owner only</td><tr><td>`3`</td><td>Owner's visibility group</td></tr><tr><td>`5`</td><td>Owner's visibility group and sub-groups</td></tr><tr><td>`7`</td><td>Entire company</td></tr></table>"
}
}
},
{
"type": "object",
"properties": {
"add_time": {
"type": "string",
"description": "The optional creation date & time of the deal in UTC. Requires admin user API token. Format: YYYY-MM-DD HH:MM:SS"
}
}
}
]
}
}
Generates:
const vSKVmFwtiCM = z.object({ title: z.string() }).and(z.object({ value: z.string(), currency: z.string(), user_id: z.number(), person_id: z.number(), org_id: z.number(), pipeline_id: z.number(), stage_id: z.number(), status: z.enum(["open", "won", "lost", "deleted"]), expected_close_date: z.string(), probability: z.number(), lost_reason: z.string(), visible_to: z.enum(["1", "3", "5", "7"]) }).partial())and(z.object({ add_time: z.string() }).partial());
Specifically:
).partial())and(z.object(
At a quick scan I believe the issue is here:
openapi-zod-client/lib/src/openApiToZod.ts
Line 125 in fa4a7fe
Sorry, disregard - my package.json autocomplete had picked a super old version of the package.