-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: parentId is sometimes invalid for shared components (#193)
* fix: parentId is sometimes invalid for shared components * test: one more level
- Loading branch information
Showing
7 changed files
with
191 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/oas3/__fixtures__/output.ts → src/oas3/__tests__/__fixtures__/id/output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/oas3/__tests__/__fixtures__/shared-components/input.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"x-stoplight": { | ||
"id": "service_abc" | ||
}, | ||
"openapi": "3.0.3", | ||
"info": { | ||
"version": "0.0.3", | ||
"title": "GitHub v3 REST API", | ||
"description": "GitHub's v3 REST API." | ||
}, | ||
"paths": { | ||
"/orgs/{org}/repos": { | ||
"get": { | ||
"summary": "Get a organization repository", | ||
"responses": { | ||
"403": { | ||
"$ref": "#/components/responses/forbidden" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"basic-error": { | ||
"title": "Basic Error", | ||
"description": "Basic Error", | ||
"type": "object", | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"rate-limit": { | ||
"title": "Rate Limit", | ||
"description": "The number of allowed requests in the current period", | ||
"type": "integer" | ||
} | ||
}, | ||
"headers": { | ||
"X-Rate-Limit": { | ||
"schema": { | ||
"$ref": "#/components/schemas/rate-limit" | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"forbidden": { | ||
"headers": { | ||
"X-Rate-Limit": { | ||
"$ref": "#/components/headers/X-Rate-Limit" | ||
} | ||
}, | ||
"description": "Forbidden", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/basic-error" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
src/oas3/__tests__/__fixtures__/shared-components/output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
NOTE that if any object anywhere ever has a `x-stoplight.id` on it, prefer that | ||
over calling the generate function. | ||
*/ | ||
export default [ | ||
/** | ||
* The http_service | ||
*/ | ||
{ | ||
// hash(document id - end user needs to be able to customize this.) | ||
// this example has a x-stoplight.id prop on the root though, so using that | ||
id: 'service_abc', | ||
version: '0.0.3', | ||
name: 'GitHub v3 REST API', | ||
description: "GitHub's v3 REST API.", | ||
}, | ||
|
||
/** | ||
* http_operation 1 of 1 (the GET operation) | ||
*/ | ||
{ | ||
// hash(`http_operation-${parentId}-${method}-${pathWithParamNamesEmpty}`) | ||
// for pathWithParamNamesEmpty, remove all characters between {} segments | ||
// closest parent with an id is the service, so ends up being... | ||
// hash('http_operation-service_abc-get-/orgs/{}/repos') | ||
id: '376a534068842', | ||
method: 'get', | ||
path: '/orgs/{org}/repos', | ||
summary: 'Get a organization repository', | ||
responses: [ | ||
{ | ||
// hash(`http_response-${parentId}-${response.code || response key (for shared response)}`) | ||
// closest parent with an id is the operation, so ends up being... | ||
// hash('http_response-service_abc-forbidden') | ||
id: 'c73bfcb376d49', | ||
code: '403', | ||
description: 'Forbidden', | ||
headers: [ | ||
{ | ||
// hash(`http_header-${parentId}-${header key}`) | ||
// it's a shared header, so the closest parent is the service. | ||
// hash('http_header-service_abc-X-Rate-Limit') | ||
id: '96620a275464f', | ||
name: 'X-Rate-Limit', | ||
style: 'simple', | ||
encodings: [], | ||
examples: [], | ||
schema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
// hash(`http_header-${parentId}-${header key}`) | ||
// it's a shared header, so the closest parent is the service. | ||
// hash('schema-service_abc-rate-limit') | ||
'x-stoplight': { | ||
id: '72da152ada960', | ||
}, | ||
type: 'integer', | ||
description: 'The number of allowed requests in the current period', | ||
title: 'Rate Limit', | ||
}, | ||
}, | ||
], | ||
contents: [ | ||
{ | ||
// hash(`http_media-${parentId}-${mediaType}`) | ||
// closest parent with an id is the response, so ends up being... | ||
// hash('http_media-c73bfcb376d49-application/json') | ||
id: '4143bd61bfef9', | ||
mediaType: 'application/json', | ||
schema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
'x-stoplight': { | ||
// hash('schema-service_abc-basic-error') | ||
id: '5cbb77597a983', | ||
}, | ||
title: 'Basic Error', | ||
description: 'Basic Error', | ||
type: 'object', | ||
properties: { | ||
message: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
examples: [], | ||
encodings: [], | ||
}, | ||
], | ||
}, | ||
], | ||
servers: [], | ||
request: { | ||
body: { | ||
id: '913ab62a764b4', | ||
contents: [], | ||
}, | ||
headers: [], | ||
query: [], | ||
cookie: [], | ||
path: [], | ||
}, | ||
tags: [], | ||
security: [], | ||
extensions: {}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters