graphql-engine/server/tests-py/queries/openapi/openapi_multiple_endpoints_same_path.yaml
David Overton 02aef27a75 Add request body to OpenAPI
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2632
Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com>
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
GitOrigin-RevId: 067e182effaed255ff047abeee309d65a9fb191c
2021-12-22 08:31:14 +00:00

178 lines
5.6 KiB
YAML

- description: Try to add a GET rest endpoint with default argument
url: /v1/query
status: 200
response:
message: success
query:
type: create_rest_endpoint
args:
url: my_endpoint_url
name: with_default_arg
methods:
- GET
definition:
query:
collection_name: test_collection
query_name: query_with_default_arg
- description: Try to add a POST rest mutation endpoint using same URL path
url: /v1/query
status: 200
response:
message: success
query:
type: create_rest_endpoint
args:
url: my_endpoint_url
name: mutation_with_args
methods:
- POST
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:
version: ''
title: Rest Endpoints
description: This OpenAPI specification is automatically generated by Hasura.
paths:
/api/rest/my_endpoint_url:
get:
summary: with_default_arg
description: "***\nThe GraphQl query for this endpoint is:\n``` graphql\n\
query ($first_name:String=\"Foo\") { test_table(where: {first_name: {\
\ _eq: $first_name } }) { first_name last_name } }\n```"
parameters:
- schema:
type: string
in: header
name: x-hasura-admin-secret
description: Your x-hasura-admin-secret will be used for authentication
of the API request.
- schema:
default: Foo
type: string
in: query
name: first_name
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
first_name:
default: Foo
type: string
nullable: true
description: Query parameters can also be provided in the request body
as a JSON object
responses:
'200':
content:
application/json:
schema:
properties:
test_table:
items:
type: object
properties:
first_name:
title: String
type: string
last_name:
title: String
type: string
type: array
nullable: false
description: Responses for GET /api/rest/my_endpoint_url
post:
summary: mutation_with_args
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:
- schema:
type: string
in: header
name: x-hasura-admin-secret
description: Your x-hasura-admin-secret will be used for authentication
of the API request.
- schema:
type: string
in: query
name: first_name
description: _"first_name" is required (enter it either in parameters or request body)_
- schema:
type: string
in: query
name: last_name
description: _"last_name" is required (enter it either in parameters or request body)_
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
first_name:
type: string
nullable: false
last_name:
type: string
nullable: false
description: Query parameters can also be provided in the request body
as a JSON object
responses:
'200':
content:
application/json:
schema:
properties:
insert_test_table:
type: object
properties:
returning:
items:
type: object
properties:
id:
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
type: array
nullable: false
affected_rows:
title: Int
type: integer
description: Responses for POST /api/rest/my_endpoint_url
components: {}
- description: Try to remove the endpoint
url: /v1/query
status: 200
response:
message: success
query:
type: drop_rest_endpoint
args:
name: with_default_arg
- description: Try to remove the endpoint
url: /v1/query
status: 200
response:
message: success
query:
type: drop_rest_endpoint
args:
name: mutation_with_args