Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

d11n/486 cleanup after 482, part 2 #507

Merged
merged 3 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
46 changes: 21 additions & 25 deletions lib/endpoint/find-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ const _ = require('lodash')
const PAGINATION_VARIABLES = [
{
name: 'per_page',
description: 'Results per page (max 100)',
in: 'query',
schema: {
type: 'integer',
default: 30
},
required: false,
description: 'Results per page (max 100)'
}
},
{
name: 'page',
description: 'Page number of the results to fetch.',
in: 'query',
schema: {
type: 'integer',
default: 1
},
required: false,
description: 'Page number of the results to fetch.'
}
}
]

Expand All @@ -40,7 +38,7 @@ function findParameters (state) {
name: 'labels',
type: 'string',
required: true,
description: '',
description: 'labels parameter',
location: 'body'
}
Object.assign(PARAMETERS_TO_INPUT, {
Expand Down Expand Up @@ -92,12 +90,12 @@ function findInRoutePath (state) {

pathParameters.push({
name,
description: `${name} parameter`,
in: 'path',
required: true,
schema: {
type: getRoutePathParameterType(name)
},
required: true,
description: `${name} parameter`
}
})
})

Expand Down Expand Up @@ -193,32 +191,32 @@ function findInBlocks (state) {

params.push({
name: 'committer',
description: 'object containing information about the committer.',
in: getParameterLocation({
method,
path,
parameter: { name: 'commiter' }
}),
schema: {
description: 'object containing information about the committer.',
type: 'object',
description: 'object containing information about the committer.',
properties: {}
},
description: 'object containing information about the committer.'
}
})

params.push({
name: 'author',
description: 'object containing information about the author.',
in: getParameterLocation({
method,
path,
parameter: { name: 'author' }
}),
schema: {
description: 'object containing information about the author.',
type: 'object',
description: 'object containing information about the author.',
properties: {}
},
description: 'object containing information about the author.'
}
})
}

Expand Down Expand Up @@ -399,12 +397,11 @@ function mapToInput (state) {
const mapToInputParam = PARAMETERS_TO_INPUT[mapKey]

if (mapToInputParam) {
const schema = buildSchema({ ...mapToInputParam })
delete schema.description
schema.description = `${mapToInputParam.name} parameter`
route.operation.requestBody = {
content: {
'application/json': { schema }
'application/json': {
schema: buildSchema({ ...mapToInputParam })
}
}
}
route.operation['x-github'].requestBodyParameterName = mapToInputParam.name
Expand All @@ -428,15 +425,15 @@ function formatParam (param) {
delete schemaParam.description
}
if (location === 'query') {
delete schemaParam.required
delete schemaParam.description
delete schemaParam.required
}
return {
name,
description: newDescription,
in: location,
schema: buildSchema(schemaParam, operation.parameters),
required,
description: newDescription
schema: buildSchema(schemaParam, operation.parameters)
}
}

Expand All @@ -451,11 +448,10 @@ function buildSchema (param, params) {
}

function initSchema (type, param) {
const schema = {}
const schema = { type }
if (param.description) {
schema.description = param.description
}
schema.type = type
if (param.enum) {
schema.enum = param.enum
}
Expand Down
20 changes: 10 additions & 10 deletions lib/endpoint/overrides/map-parameters-to-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,70 @@ module.exports = {
name: 'data',
type: 'string',
required: true,
description: '',
description: 'data parameter',
location: 'body'
},
'PUT /repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts': {
name: 'contexts',
type: 'string[]',
required: true,
description: '',
description: 'contexts parameter',
location: 'body'
},
'POST /repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts': {
name: 'contexts',
type: 'string[]',
required: true,
description: '',
description: 'contexts parameter',
location: 'body'
},
'DELETE /repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts': {
name: 'contexts',
type: 'string[]',
required: true,
description: '',
description: 'contexts parameter',
location: 'body'
},
'PUT /repos/:owner/:repo/branches/:branch/protection/restrictions/teams': {
name: 'teams',
type: 'string[]',
required: true,
description: '',
description: 'teams parameter',
location: 'body'
},
'POST /repos/:owner/:repo/branches/:branch/protection/restrictions/teams': {
name: 'teams',
type: 'string[]',
required: true,
description: '',
description: 'teams parameter',
location: 'body'
},
'DELETE /repos/:owner/:repo/branches/:branch/protection/restrictions/teams': {
name: 'teams',
type: 'string[]',
required: true,
description: '',
description: 'teams parameter',
location: 'body'
},
'PUT /repos/:owner/:repo/branches/:branch/protection/restrictions/users': {
name: 'users',
type: 'string[]',
required: true,
description: '',
description: 'users parameter',
location: 'body'
},
'POST /repos/:owner/:repo/branches/:branch/protection/restrictions/users': {
name: 'users',
type: 'string[]',
required: true,
description: '',
description: 'users parameter',
location: 'body'
},
'DELETE /repos/:owner/:repo/branches/:branch/protection/restrictions/users': {
name: 'users',
type: 'string[]',
required: true,
description: '',
description: 'users parameter',
location: 'body'
}
}
62 changes: 47 additions & 15 deletions lib/endpoint/overrides/v3/git/refs/get-a-reference.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[
{
"method": "GET",
"path": "/repos/:owner/:repo/git/refs/:ref",
"method": "get",
"operation": {
"summary": "Get a reference",
"description": "Returns a branch or tag reference. Other than the [REST API](https://developer.github.com/v3/git/refs/#get-a-reference) it always returns a single reference. If the REST API returns with an array then the method responds with an error.",
"operationId": "git-get-ref",
"operationId": "git/get-ref",
"tags": [
"git"
],
Expand All @@ -25,45 +25,77 @@
},
{
"name": "owner",
"description": "owner parameter",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"required": true,
"description": "owner parameter"
}
},
{
"name": "repo",
"description": "repo parameter",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"required": true,
"description": "repo parameter"
}
},
{
"name": "ref",
"description": "Must be formatted as `heads/branch`, not just `branch`",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"required": true,
"description": "Must be formatted as `heads/branch`, not just `branch`"
}
}
],
"responses": {
"418": {
"description": "Response definition missing"
"200": {
"description": "response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"ref": {
"type": "string"
},
"node_id": {
"type": "string"
},
"url": {
"type": "string"
},
"object": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"sha": {
"type": "string"
},
"url": {
"type": "string"
}
}
}
}
}
}
}
}
},
"x-code-samples": [
{
"lang": "Shell",
"source": "curl \\\n -H\"Accept: application/vnd.github.v3+json\" \\\n https://developer.github.com/repos/octocat/:repo/git/refs/:ref"
"source": "curl \\\n -H\"Accept: application/vnd.github.v3+json\" \\\n https://developer.github.com/repos/octocat/hello-world/git/refs/REF"
},
{
"lang": "JS",
"source": "octokit.git.get({\n owner: 'octocat',\n repo: 'hello-world',\n ref: 'ref'\n})"
"source": "octokit.git.getRef({\n owner: 'octocat',\n repo: 'hello-world',\n ref: 'ref'\n})"
}
],
"x-github": {
Expand Down
Loading