-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/openapi expanded contenttype (#4228)
* feat: expand content type handling in openapi handler. possibly resolves for issue #3044 * Add a changeset * Go Co-authored-by: JB Smith <[email protected]>
- Loading branch information
1 parent
4f6397f
commit 31d5f6e
Showing
5 changed files
with
157 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-mesh/openapi': patch | ||
--- | ||
|
||
feat: expand content type handling in openapi handler. possibly resolves for issue #3044 |
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
36 changes: 36 additions & 0 deletions
36
packages/handlers/openapi/test/cloudfunction_expanded.test.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,36 @@ | ||
// Copyright IBM Corp. 2017. All Rights Reserved. | ||
// Node module: openapi-to-graphql | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
'use strict'; | ||
|
||
/* globals beforeAll, test, expect */ | ||
|
||
import * as openAPIToGraphQL from '../src/openapi-to-graphql/index'; | ||
import { GraphQLSchema, parse, validate } from 'graphql'; | ||
import { fetch } from '@whatwg-node/fetch'; | ||
|
||
const oas = require('./fixtures/cloudfunction_expanded.json'); | ||
|
||
let createdSchema: GraphQLSchema; | ||
|
||
beforeAll(async () => { | ||
const { schema } = await openAPIToGraphQL.createGraphQLSchema(oas, { fetch }); | ||
createdSchema = schema; | ||
}); | ||
|
||
test('Get response', async () => { | ||
const query = `mutation { | ||
mutationViewerBasicAuth (username: "test" password: "data") { | ||
postTestAction2 (payloadInput: {age: 27}) { | ||
payload | ||
age | ||
} | ||
} | ||
}`; | ||
// validate that 'limit' parameter is covered by options: | ||
const ast = parse(query); | ||
const errors = validate(createdSchema, ast); | ||
expect(errors).toEqual([]); | ||
}); |
108 changes: 108 additions & 0 deletions
108
packages/handlers/openapi/test/fixtures/cloudfunction_expanded.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,108 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "test-action-2-expanded", | ||
"version": "1.0.0" | ||
}, | ||
"paths": { | ||
"/test-action-2": { | ||
"post": { | ||
"description": "Description of the action", | ||
"responses": { | ||
"200": { | ||
"description": "Success response for test-action-2-expanded", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Response" | ||
} | ||
} | ||
} | ||
}, | ||
"default": { | ||
"description": "Error response for test-action-2-expanded", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Error" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "blocking", | ||
"in": "query", | ||
"schema": { | ||
"type": "boolean", | ||
"default": true | ||
} | ||
}, | ||
{ | ||
"name": "result", | ||
"in": "query", | ||
"schema": { | ||
"type": "boolean", | ||
"default": true | ||
} | ||
} | ||
], | ||
"security": [ | ||
{ | ||
"basic_protocol": [] | ||
} | ||
], | ||
"requestBody": { | ||
"content": { | ||
"application/vnd.experimental+json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Payload" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "https://openwhisk.ng.bluemix.net/api/v1/namespaces/_/actions" | ||
} | ||
], | ||
"components": { | ||
"schemas": { | ||
"Response": { | ||
"type": "object", | ||
"properties": { | ||
"payload": { | ||
"type": "string" | ||
}, | ||
"age": { | ||
"type": "number" | ||
}, | ||
"valid": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": ["payload", "age", "valid"] | ||
}, | ||
"Error": {}, | ||
"Payload": { | ||
"type": "object", | ||
"properties": { | ||
"age": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": ["age"] | ||
} | ||
}, | ||
"securitySchemes": { | ||
"basic_protocol": { | ||
"type": "http", | ||
"scheme": "basic" | ||
} | ||
} | ||
} | ||
} |
31d5f6e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
graphql-mesh – ./
graphql-mesh-git-master-theguild.vercel.app
graphql-mesh.com
graphql-mesh-theguild.vercel.app
www.graphql-mesh.com
graphql-mesh-azure.vercel.app