diff --git a/lib/endpoint/overrides/workarounds.js b/lib/endpoint/overrides/workarounds.js index 6f95fb347b..f8d5706000 100644 --- a/lib/endpoint/overrides/workarounds.js +++ b/lib/endpoint/overrides/workarounds.js @@ -154,6 +154,36 @@ function gistWorkarounds(route) { const { operation } = route; const restPattern = route.method + " " + route.path; + const gistFiles = { + type: "object", + additionalProperties: { + type: "object", + properties: { + filename: { type: "string" }, + type: { type: "string" }, + language: { type: "string" }, + raw_url: { type: "string" }, + size: { type: "number" }, + truncated: { type: "boolean" }, + content: { type: "string" }, + }, + }, + }; + + const gistBaseFiles = { + type: "object", + additionalProperties: { + type: "object", + properties: { + filename: { type: "string" }, + type: { type: "string" }, + language: { type: "string" }, + raw_url: { type: "string" }, + size: { type: "number" }, + }, + }, + }; + // Allows you to update or delete a gist file and rename gist files. // Files from the previous version of the gist that aren't explicitly // changed during an edit are unchanged. @@ -179,27 +209,17 @@ function gistWorkarounds(route) { }, }, }; + + operation.responses[200].content[ + "application/json" + ].schema.properties.files = gistFiles; } // see https://developer.github.com/v3/gists/#get-a-gist if (restPattern === "GET /gists/:gist_id") { operation.responses[200].content[ "application/json" - ].schema.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - truncated: { type: "boolean" }, - content: { type: "string" }, - }, - }, - }; + ].schema.properties.files = gistFiles; } // Allows you to add a new gist with one or more files. @@ -224,117 +244,47 @@ function gistWorkarounds(route) { operation.responses[201].content[ "application/json" - ].schema.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - truncated: { type: "boolean" }, - content: { type: "string" }, - }, - }, - }; + ].schema.properties.files = gistFiles; } // see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist if (restPattern === "GET /gists/:gist_id/:sha") { operation.responses[200].content[ "application/json" - ].schema.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - truncated: { type: "boolean" }, - content: { type: "string" }, - }, - }, - }; + ].schema.properties.files = gistFiles; } // see https://developer.github.com/v3/gists/#list-gists-for-the-authenticated-user if (restPattern === "GET /gists") { operation.responses[200].content[ "application/json" - ].schema.items.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - }, - }, - }; + ].schema.items.properties.files = gistBaseFiles; } // see https://developer.github.com/v3/gists/#list-public-gists if (restPattern === "GET /gists/public") { operation.responses[200].content[ "application/json" - ].schema.items.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - }, - }, - }; + ].schema.items.properties.files = gistBaseFiles; } // see https://developer.github.com/v3/gists/#list-starred-gists if (restPattern === "GET /gists/starred") { operation.responses[200].content[ "application/json" - ].schema.items.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - }, - }, - }; + ].schema.items.properties.files = gistBaseFiles; } // see https://developer.github.com/v3/gists/#list-gists-for-a-user if (restPattern === "GET /users/:username/gists") { operation.responses[200].content[ "application/json" - ].schema.items.properties.files = { - type: "object", - additionalProperties: { - type: "object", - properties: { - filename: { type: "string" }, - type: { type: "string" }, - language: { type: "string" }, - raw_url: { type: "string" }, - size: { type: "number" }, - }, - }, - }; + ].schema.items.properties.files = gistBaseFiles; + } + + if (restPattern === "POST /gists/:gist_id/forks") { + operation.responses[201].content[ + "application/json" + ].schema.properties.files = gistBaseFiles; } } diff --git a/openapi/api.github.com/operations/gists/fork.json b/openapi/api.github.com/operations/gists/fork.json index 27db4474c6..d2fdc04364 100644 --- a/openapi/api.github.com/operations/gists/fork.json +++ b/openapi/api.github.com/operations/gists/fork.json @@ -42,16 +42,14 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" } } } }, diff --git a/openapi/api.github.com/operations/gists/update.json b/openapi/api.github.com/operations/gists/update.json index d9690ed8bb..1571633fed 100644 --- a/openapi/api.github.com/operations/gists/update.json +++ b/openapi/api.github.com/operations/gists/update.json @@ -42,54 +42,16 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.py": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.md": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "new_file.txt": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" }, + "truncated": { "type": "boolean" }, + "content": { "type": "string" } } } }, diff --git a/openapi/ghe-2.17/operations/gists/fork.json b/openapi/ghe-2.17/operations/gists/fork.json index 6f4af2460a..281b32dc82 100644 --- a/openapi/ghe-2.17/operations/gists/fork.json +++ b/openapi/ghe-2.17/operations/gists/fork.json @@ -42,16 +42,14 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" } } } }, diff --git a/openapi/ghe-2.17/operations/gists/update.json b/openapi/ghe-2.17/operations/gists/update.json index 8f1d6dbcfc..f874e44c75 100644 --- a/openapi/ghe-2.17/operations/gists/update.json +++ b/openapi/ghe-2.17/operations/gists/update.json @@ -42,54 +42,16 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.py": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.md": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "new_file.txt": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" }, + "truncated": { "type": "boolean" }, + "content": { "type": "string" } } } }, diff --git a/openapi/ghe-2.18/operations/gists/fork.json b/openapi/ghe-2.18/operations/gists/fork.json index 9fa69b9024..ce9f353769 100644 --- a/openapi/ghe-2.18/operations/gists/fork.json +++ b/openapi/ghe-2.18/operations/gists/fork.json @@ -42,16 +42,14 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" } } } }, diff --git a/openapi/ghe-2.18/operations/gists/update.json b/openapi/ghe-2.18/operations/gists/update.json index 5431f0a9e5..5ce261b99e 100644 --- a/openapi/ghe-2.18/operations/gists/update.json +++ b/openapi/ghe-2.18/operations/gists/update.json @@ -42,54 +42,16 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.py": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.md": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "new_file.txt": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" }, + "truncated": { "type": "boolean" }, + "content": { "type": "string" } } } }, diff --git a/openapi/ghe-2.19/operations/gists/fork.json b/openapi/ghe-2.19/operations/gists/fork.json index 90b9df1f27..ab38968a27 100644 --- a/openapi/ghe-2.19/operations/gists/fork.json +++ b/openapi/ghe-2.19/operations/gists/fork.json @@ -42,16 +42,14 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" } } } }, diff --git a/openapi/ghe-2.19/operations/gists/update.json b/openapi/ghe-2.19/operations/gists/update.json index 8d47acd04e..112b979915 100644 --- a/openapi/ghe-2.19/operations/gists/update.json +++ b/openapi/ghe-2.19/operations/gists/update.json @@ -42,54 +42,16 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.py": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.md": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "new_file.txt": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" }, + "truncated": { "type": "boolean" }, + "content": { "type": "string" } } } }, diff --git a/openapi/ghe-2.20/operations/gists/fork.json b/openapi/ghe-2.20/operations/gists/fork.json index 8cdb8c2d26..bc531b3aa9 100644 --- a/openapi/ghe-2.20/operations/gists/fork.json +++ b/openapi/ghe-2.20/operations/gists/fork.json @@ -42,16 +42,14 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" } } } }, diff --git a/openapi/ghe-2.20/operations/gists/update.json b/openapi/ghe-2.20/operations/gists/update.json index b3e2dc6f1d..3c779252bd 100644 --- a/openapi/ghe-2.20/operations/gists/update.json +++ b/openapi/ghe-2.20/operations/gists/update.json @@ -42,54 +42,16 @@ "html_url": { "type": "string" }, "files": { "type": "object", - "properties": { - "hello_world.rb": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.py": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "hello_world.md": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } - }, - "new_file.txt": { - "type": "object", - "properties": { - "filename": { "type": "string" }, - "type": { "type": "string" }, - "language": { "type": "string" }, - "raw_url": { "type": "string" }, - "size": { "type": "number" }, - "truncated": { "type": "boolean" }, - "content": { "type": "string" } - } + "additionalProperties": { + "type": "object", + "properties": { + "filename": { "type": "string" }, + "type": { "type": "string" }, + "language": { "type": "string" }, + "raw_url": { "type": "string" }, + "size": { "type": "number" }, + "truncated": { "type": "boolean" }, + "content": { "type": "string" } } } },