Skip to content

Commit

Permalink
openAPI handler tests migration (#4235)
Browse files Browse the repository at this point in the history
* some tests

* lowercase header fix

* add missing Proxy fields

* */* access header fix

* cookies srtingify fix

* test server fix

* If additionalProperties is basically type: string, ignore (#4274)

* more informative error message

* Fix union handling (#4289)

* Make arguments related to query params nullable if it is already defined in queryParams (#4290)

* Error extensions and fix JSON scalars (#4292)

* convert format uuid into UUID scalar

* remove type args if provided by operationHeaders

* fix for Query.getFields

* Do not respect user's accept header if we have a better option (#4272)

* Openapi multiple argument sources fix (#4311)

* Add a changeset

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Arda TANRIKULU <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 17, 2022
1 parent e545ffb commit b162269
Show file tree
Hide file tree
Showing 21 changed files with 2,492 additions and 1,255 deletions.
36 changes: 36 additions & 0 deletions .changeset/bright-bags-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
"@graphql-mesh/openapi": minor
"@omnigraph/json-schema": minor
"@omnigraph/openapi": minor
---

- Support "$request.query" and "$request.path" usages in [OpenAPI runtime expressions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)
- Fix `Field not found` error when an OpenAPI link refers to an operation which is not `Mutation`
- Do not use AJV and check field names in the received object to resolve the type name for a union field
- Fix `queryParams` which allows you to pass query parameters for all operations
- Handle cookie paramters correctly defined in the OpenAPI document by trimming empty values
- Respect the mime types defined in the OpenAPI document. Now it creates a union for each mime type defined in the document, and resolve it by the mime type.
- Respect JSON examples given in the OpenAPI document correctly even if they are strings with JSON content.
- Normalize(lowercase header names) and merge final operation headers correctly from different places `operationHeaders` from the bundle and configuration plus `headers` defined for that specific operation.

**BREAKING CHANGES:**

- If a JSON Schema type cannot be represented in GraphQL (object without properties etc.), it will no longer use `Any` type but `JSON` type instead which is a scalar from `graphql-scalars`.

- Due to the improvements in `healJSONSchema` some of types that are not named in the JSON Schema might be named in a different way. Please make sure the content of the types are correct and report us on GitHub if they are represented incorrectly.

- UUID format is now represented as `UUID` scalar type which is a scalar from `graphql-scalars`.

- HTTP Errors are now in a more descriptive way. If your consumer respects them strictly, they will probably need to update their implementation.

```diff
{
"url": "http://www.google.com/api",
"method": "GET",
- "status": 401,
+ "statusCode": 401,
+ "statusText": "Unauthorized",
- "responseJson": {}
+ "responseBody": {}
}
```
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`JSON Schema Example should generate correct schema 1`] = `
"scalar Any
\\"\\"\\"Fake Company\\"\\"\\"
"\\"\\"\\"Fake Company\\"\\"\\"
type Company {
employers: [User]
name: String
Expand All @@ -29,9 +27,14 @@ type Foo {
id: String
}
\\"\\"\\"
The \`JSON\` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
\\"\\"\\"
scalar JSON @specifiedBy(url: \\"http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf\\")
type Mutation {
createUser(input: CreateUpdateUserInput): User
deleteUser(id: ID!): Any
deleteUser(id: ID!): JSON
updateUser(id: ID!, input: CreateUpdateUserInput): User
}
Expand Down
Loading

1 comment on commit b162269

@vercel
Copy link

@vercel vercel bot commented on b162269 Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.