graphql-engine/server/tests-py/queries/openapi/openapi_endpoint_with_multiple_methods.yaml
Samir Talwar dd46aa6715 server: Preserve ordering when possible, and sort when it's not.
When upgrading to GHC v9.4, we noticed a number of failures because the sort order of HashMaps has changed. With this changeset, I am endeavoring to mitigate this now and in the future.

This makes one of two changes in a few areas where we depend on the sort order of elements in a `HashMap`:

  1. the ordering of the request is preserved with `InsOrdHashMap`, or
  2. we sort the data after retrieving it.

Fortunately, we do not do this anywhere where we _must_ preserve order; it's "just" descriptions, error messages, and OpenAPI metadata. The main problem is that tests are likely to fail each time we upgrade GHC (or whatever is providing the hash seed).

[NDAT-705]: https://hasurahq.atlassian.net/browse/NDAT-705?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9390
GitOrigin-RevId: 84503e029b44094edbbc298651744bc2843c15f3
2023-06-02 09:31:26 +00:00

402 lines
15 KiB
YAML

- description: Try to add a rest endpoint with multiple methods
url: /v1/query
status: 200
response:
message: success
query:
type: create_rest_endpoint
args:
url: multi_method_endpoint
name: multi_method_endpoint
methods:
- GET
- POST
- PUT
- DELETE
- PATCH
definition:
query:
collection_name: test_collection
query_name: mutation_with_args
- description: Call openapi json endpoint
url: /api/swagger/json
method: GET
status: 200
query:
response:
openapi: 3.0.0
info:
description: This OpenAPI specification is automatically generated by Hasura.
title: Rest Endpoints
version: ''
paths:
/api/rest/multi_method_endpoint:
get:
summary: multi_method_endpoint
description: "***\nThe GraphQl query for this endpoint is:\n``` graphql\n\
mutation ($first_name: String!, $last_name: String!) { insert_test_table(\
\ objects: {first_name: $first_name, last_name: $last_name }) { returning\
\ { id } affected_rows } }\n```"
parameters:
- description: Your x-hasura-admin-secret will be used for authentication
of the API request.
in: header
name: x-hasura-admin-secret
schema:
type: string
- description: _"first_name" is required (enter it either in parameters
or request body)_
in: query
name: first_name
schema:
type: string
- description: _"last_name" is required (enter it either in parameters or
request body)_
in: query
name: last_name
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
first_name:
nullable: false
title: String
type: string
last_name:
nullable: false
title: String
type: string
type: object
description: Query parameters can also be provided in the request body
as a JSON object
required: false
responses:
'200':
content:
application/json:
schema:
properties:
insert_test_table:
description: response of any mutation on the table "test_table"
nullable: true
properties:
affected_rows:
nullable: false
title: Int
type: integer
returning:
items:
description: columns and relationships of "test_table"
nullable: false
properties:
id:
$ref: '#/components/schemas/uuid!'
title: test_table
type: object
nullable: false
type: array
title: test_table_mutation_response
type: object
description: Responses for GET /api/rest/multi_method_endpoint
put:
summary: multi_method_endpoint
description: "***\nThe GraphQl query for this endpoint is:\n``` graphql\n\
mutation ($first_name: String!, $last_name: String!) { insert_test_table(\
\ objects: {first_name: $first_name, last_name: $last_name }) { returning\
\ { id } affected_rows } }\n```"
parameters:
- description: Your x-hasura-admin-secret will be used for authentication
of the API request.
in: header
name: x-hasura-admin-secret
schema:
type: string
- description: _"first_name" is required (enter it either in parameters
or request body)_
in: query
name: first_name
schema:
type: string
- description: _"last_name" is required (enter it either in parameters or
request body)_
in: query
name: last_name
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
first_name:
nullable: false
title: String
type: string
last_name:
nullable: false
title: String
type: string
type: object
description: Query parameters can also be provided in the request body
as a JSON object
required: false
responses:
'200':
content:
application/json:
schema:
properties:
insert_test_table:
description: response of any mutation on the table "test_table"
nullable: true
properties:
affected_rows:
nullable: false
title: Int
type: integer
returning:
items:
description: columns and relationships of "test_table"
nullable: false
properties:
id:
$ref: '#/components/schemas/uuid!'
title: test_table
type: object
nullable: false
type: array
title: test_table_mutation_response
type: object
description: Responses for PUT /api/rest/multi_method_endpoint
post:
summary: multi_method_endpoint
description: "***\nThe GraphQl query for this endpoint is:\n``` graphql\n\
mutation ($first_name: String!, $last_name: String!) { insert_test_table(\
\ objects: {first_name: $first_name, last_name: $last_name }) { returning\
\ { id } affected_rows } }\n```"
parameters:
- description: Your x-hasura-admin-secret will be used for authentication
of the API request.
in: header
name: x-hasura-admin-secret
schema:
type: string
- description: _"first_name" is required (enter it either in parameters
or request body)_
in: query
name: first_name
schema:
type: string
- description: _"last_name" is required (enter it either in parameters or
request body)_
in: query
name: last_name
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
first_name:
nullable: false
title: String
type: string
last_name:
nullable: false
title: String
type: string
type: object
description: Query parameters can also be provided in the request body
as a JSON object
required: false
responses:
'200':
content:
application/json:
schema:
properties:
insert_test_table:
description: response of any mutation on the table "test_table"
nullable: true
properties:
affected_rows:
nullable: false
title: Int
type: integer
returning:
items:
description: columns and relationships of "test_table"
nullable: false
properties:
id:
$ref: '#/components/schemas/uuid!'
title: test_table
type: object
nullable: false
type: array
title: test_table_mutation_response
type: object
description: Responses for POST /api/rest/multi_method_endpoint
delete:
summary: multi_method_endpoint
description: "***\nThe GraphQl query for this endpoint is:\n``` graphql\n\
mutation ($first_name: String!, $last_name: String!) { insert_test_table(\
\ objects: {first_name: $first_name, last_name: $last_name }) { returning\
\ { id } affected_rows } }\n```"
parameters:
- description: Your x-hasura-admin-secret will be used for authentication
of the API request.
in: header
name: x-hasura-admin-secret
schema:
type: string
- description: _"first_name" is required (enter it either in parameters
or request body)_
in: query
name: first_name
schema:
type: string
- description: _"last_name" is required (enter it either in parameters or
request body)_
in: query
name: last_name
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
first_name:
nullable: false
title: String
type: string
last_name:
nullable: false
title: String
type: string
type: object
description: Query parameters can also be provided in the request body
as a JSON object
required: false
responses:
'200':
content:
application/json:
schema:
properties:
insert_test_table:
description: response of any mutation on the table "test_table"
nullable: true
properties:
affected_rows:
nullable: false
title: Int
type: integer
returning:
items:
description: columns and relationships of "test_table"
nullable: false
properties:
id:
$ref: '#/components/schemas/uuid!'
title: test_table
type: object
nullable: false
type: array
title: test_table_mutation_response
type: object
description: Responses for DELETE /api/rest/multi_method_endpoint
patch:
summary: multi_method_endpoint
description: "***\nThe GraphQl query for this endpoint is:\n``` graphql\n\
mutation ($first_name: String!, $last_name: String!) { insert_test_table(\
\ objects: {first_name: $first_name, last_name: $last_name }) { returning\
\ { id } affected_rows } }\n```"
parameters:
- description: Your x-hasura-admin-secret will be used for authentication
of the API request.
in: header
name: x-hasura-admin-secret
schema:
type: string
- description: _"first_name" is required (enter it either in parameters
or request body)_
in: query
name: first_name
schema:
type: string
- description: _"last_name" is required (enter it either in parameters or
request body)_
in: query
name: last_name
schema:
type: string
requestBody:
content:
application/json:
schema:
properties:
first_name:
nullable: false
title: String
type: string
last_name:
nullable: false
title: String
type: string
type: object
description: Query parameters can also be provided in the request body
as a JSON object
required: false
responses:
'200':
content:
application/json:
schema:
properties:
insert_test_table:
description: response of any mutation on the table "test_table"
nullable: true
properties:
affected_rows:
nullable: false
title: Int
type: integer
returning:
items:
description: columns and relationships of "test_table"
nullable: false
properties:
id:
$ref: '#/components/schemas/uuid!'
title: test_table
type: object
nullable: false
type: array
title: test_table_mutation_response
type: object
description: Responses for PATCH /api/rest/multi_method_endpoint
components:
schemas:
uuid!:
nullable: false
pattern: '[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}'
title: uuid
type: string
- description: Try to remove the endpoint
url: /v1/query
status: 200
response:
message: success
query:
type: drop_rest_endpoint
args:
name: multi_method_endpoint