mattpolzin / OpenAPIKit

Codable Swift OpenAPI implementation.
MIT License
282 stars 35 forks source link

Accessing vendor extensions at `JSONSchema`/property level #330

Closed daniloc closed 11 months ago

daniloc commented 11 months ago

Hello! Thanks for a great project. Already very helpful, but I'm scratching my head on this point:

I've got some schema properties that have a vendor extension, as in:

  "Input": {
    "properties": {
      "apply_watermark": {
        "default": true,
        "description": "[…]",
        "title": "Apply Watermark",
        "type": "boolean",
        "x-order": 15
      }

But when I inspect the parsed document with the debugger, I don't find x-order represented anywhere. From my reading in the docs and source, I know the project has some support for vendor extensions already, but I did not see any action in JSONSchema, which appears to represent these properties, for parsing these in at that level.

Am I correct about this?

Your management of abstractions to handle all the variations these documents can represent is just a bit over my head, but if you can provide a bare sketch of what is missing, happy to take a swing at a PR to address this, if that helps.

Otherwise, let me know if there's something conceptual I'm missing and I'll see about a patch to the docs! Thanks so much for your time here.

mattpolzin commented 11 months ago

OpenAPIKit gained support for JSONSchema vendor extensions in a recent pre-release version.

It wasn't possible to add support for vendor extensions without a breaking change, so they won't be coming to v2.x of OpenAPIKit.

Check out https://github.com/mattpolzin/OpenAPIKit/tree/3.0.0-rc.2 if you are on v2.x of OpenAPIKit or even an earlier pre-release version. If you have a lot of OpenAPIKit code written, there will likely be some breaking changes for you to work through, but I did my best to document them all here: https://github.com/mattpolzin/OpenAPIKit/blob/3.0.0-rc.2/documentation/v3_migration_guide.md.

I didn't have exactly the situation you describe in a test case already, so I went ahead and added one. That means you can see the way to access the vendor extensions by looking at the tests in this commit: https://github.com/mattpolzin/OpenAPIKit/commit/5a937cb4339582bbe5898b260339a470e998a2ff#diff-c29d55d1cb0243fc2ecf7f07658ac8d30d4b8a9a11efff28d84faa61dac78096R3088

daniloc commented 11 months ago

BRILLIANT! Working perfectly, a seamless swap. Thank you for your kind, thorough and prompt attention, Matt, and thanks again for this excellent project. Wishing you a great week ahead.