openapi icon indicating copy to clipboard operation
openapi copied to clipboard

Use more definitions instead of repeating type data?

Open mohawk2 opened this issue 7 years ago • 2 comments

Hi, in at least the v2 spec, in JSON Pointer speak this:

/paths/~1v1~1accounts/post/parameters/0/schema/properties/legal_entity/additional_owners/properties

has string keys of "0", "1", ... and each of those values is identical:

                        "0": {
                          "properties": {
                            "address": {
                              "properties": {
                                "city": {
                                  "type": [
                                    "string"
                                  ]
                                },

etc. These could all each instead be:

                        "0": { "$ref": "#/definitions/legal_entity_definition" },

or similar. Out of the currently 41k line spec, that would already save about 100 x 30 = 3k. There are probably more examples.

mohawk2 avatar Dec 19 '17 16:12 mohawk2

Thanks for logging. And yes, it seems like a good idea to fix this.

I'm not sure I'll get to this soon as this part of the generator is a little involved. If size is a problem I'd suggest compression — even without these duplicates the spec is highly repetitive and a gzip should work really well.

brandur-stripe avatar Dec 19 '17 19:12 brandur-stripe

If you'd publish that code I'd be pleased to provide a fix myself. However I'm more concerned with the "type is an array" incompatibility or the non-unique operationId!

mohawk2 avatar Dec 20 '17 07:12 mohawk2

I apologize for the extremely delayed response. This has been fixed. We don't generate numerical string keys with duplicated values anymore.

pakrym-stripe avatar Jan 17 '23 16:01 pakrym-stripe