highsidelabs / saloon-sdk-generator

Generate Saloon SDKs from Postman Collections and OpenAPI Specifications.
MIT License
2 stars 5 forks source link

Check for circular references when parsing schemas #8

Closed jlevers closed 3 months ago

jlevers commented 3 months ago

@dpash this appears to fix https://github.com/jlevers/selling-partner-api/issues/719. Just want to check that the solution seems sane to you.

dpash commented 3 months ago

I've just tested this and yes, this seems to generate correct output now.

dpash commented 3 months ago

Regenerating the library does fix the new catalog items schema, but we now lose OrderedQuantity::$orderedQuantity in the vendors Orders v1 schema. That's the only other change, so it could have been worse :) I'll see if I can figure out why.

jlevers commented 3 months ago

Hah, I'm working on the same problem right now. It has to do with the recursion fix (#8), but I haven't yet figured out how to resolve it in a way that makes sense.

dpash commented 3 months ago

Okay, I think I have found a "solution" which is to also compare the description of the schema and the ancestor, which isn't ideal, but does work.

if ($_parent->rawName === $name && $_parent->description === $schema->description) {
jlevers commented 3 months ago

Yeah, that seems like a good enough solution for now. If it becomes a problem again at some point we can revisit it, but I think doing this properly will involve some sorta actual schema object comparator function which seems like overkill for now.

jlevers commented 3 months ago

I pushed that fix – I'll regenerate again once https://github.com/jlevers/selling-partner-api/pull/731 is merged.