Skip to content

Commit

Permalink
Merge pull request #8 from speakeasy-sdks/chore/sync-template-sdk-spec
Browse files Browse the repository at this point in the history
chore: sync spec from template-sdk repo
  • Loading branch information
2ynn authored Feb 29, 2024
2 parents 6d12090 + 7a3d647 commit c365064
Showing 1 changed file with 94 additions and 9 deletions.
103 changes: 94 additions & 9 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ servers:
- dev
security:
- apiKey: []
- bearerAuth: []
tags:
- name: drinks
description: The drinks endpoints.
Expand All @@ -57,22 +58,33 @@ paths:
- 5XX
/authenticate:
post:
operationId: authenticate
operationId: login
summary: Authenticate with the API by providing a username and password.
security: []
security:
- basicHttp: []
tags:
- authentication
x-speakeasy-usage-example:
title: "Sign in"
description: |-
First you need to send an authentication request to the API by providing your username and password.
In the request body, you should specify the type of token you would like to receive: API key or JSON Web Token.
If your credentials are valid, you will receive a token in the response object: `res.object.token: str`.
position: 1
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- type
properties:
username:
type: string
password:
type:
type: string
enum:
- apiKey
- JWT
responses:
"200":
description: The api key to use for authenticated endpoints.
Expand All @@ -89,15 +101,23 @@ paths:
$ref: "#/components/responses/APIError"
default:
$ref: "#/components/responses/UnknownError"

/drinks:
get:
x-speakeasy-usage-example: true
operationId: listDrinks
summary: Get a list of drinks.
description: Get a list of drinks, if authenticated this will include stock levels and product codes otherwise it will only include public information.
security:
- bearerAuth: []
- {}
x-speakeasy-usage-example:
title: "Browse available drinks"
description: |-
Once you are authenticated, you can use the token you received for all other authenticated endpoints.
For example, you can filter the list of available drinks by type.
position: 2
servers:
- url: https://speakeasy.bar
- url: https://test.speakeasy.bar
tags:
- drinks
parameters:
Expand All @@ -120,7 +140,6 @@ paths:
$ref: "#/components/responses/APIError"
default:
$ref: "#/components/responses/UnknownError"

/drink/{name}: #TODO: this should be by product code and we should have search by name
get:
operationId: getDrink
Expand Down Expand Up @@ -151,6 +170,16 @@ paths:
operationId: listIngredients
summary: Get a list of ingredients.
description: Get a list of ingredients, if authenticated this will include stock levels and product codes otherwise it will only include public information.
x-speakeasy-usage-example:
description: |-
Specifying tags for this extension allows selecting the operation for specific README sections.
If the "tags" array is not provided or if it contains the tag "usage", a usage snippet associated
with the operation will be inserted in the main "SDK Example Usage" section. In this case a "title"
and "description" can be provided for this example and its relative positioning can be set through
the "position" attribute. "title", "description" and "position" have no effect for other tags.
tags:
- server # Server Selection
- security # Authentication
tags:
- ingredients
parameters:
Expand Down Expand Up @@ -185,6 +214,12 @@ paths:
description: Create an order for a drink.
tags:
- orders
x-speakeasy-usage-example:
title: "Create an order"
description: |-
When you submit an order, you can include a callback URL along your request.
This URL will get called whenever the supplier updates the status of your order.
position: 3
parameters:
- name: callback_url
in: query
Expand Down Expand Up @@ -242,6 +277,23 @@ paths:
description: Subscribe to webhooks.
tags:
- config
x-speakeasy-usage-example:
title: "Subscribe to webhooks to receive stock updates"
position: 3
tags:
- usage # SDK Example Usage
- retries # Retries
- errors # Error Handling
x-speakeasy-retries:
strategy: backoff
backoff:
initialInterval: 10 # 10 ms
maxInterval: 200 # 200 ms
maxElapsedTime: 1000 # 1 seconds
exponent: 1.5
statusCodes:
- 404
retryConnectionErrors: false
requestBody:
required: true
content:
Expand All @@ -260,6 +312,8 @@ paths:
responses:
"200":
description: The webhook was subscribed to successfully.
"400":
$ref: "#/components/responses/BadRequest"
"5XX":
$ref: "#/components/responses/APIError"
default:
Expand Down Expand Up @@ -299,9 +353,25 @@ components:
type: string
message:
type: string
x-speakeasy-error-message: true
details:
type: object
additionalProperties: true
BadRequest:
type: object
properties:
status_code:
type: number
description: HTTP status code
example: 400
error:
type: string
description: Contains an explanation of the status_code as defined in HTTP/1.1 standard (RFC 7231)
example: Bad Request
type_name:
type: string
description: The type of error returned
example: RequestValidationError
Error:
type: object
properties:
Expand Down Expand Up @@ -430,16 +500,31 @@ components:
type: apiKey
name: Authorization
in: header
x-speakeasy-example: <YOUR_API_KEY>
bearerAuth:
type: http
scheme: bearer
x-speakeasy-example: <YOUR_JWT>
basicHttp:
type: http
scheme: basic
x-speakeasy-example: <USERNAME>;<PASSWORD>
responses:
APIError:
description: An error occurred interacting with the API.
content:
application/json:
schema:
$ref: "#/components/schemas/APIError"
BadRequest:
description: Bad Request
content:
application/json:
schema:
$ref: "#/components/schemas/BadRequest"
UnknownError:
description: An unknown error occurred interacting with the API.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
$ref: "#/components/schemas/Error"

0 comments on commit c365064

Please sign in to comment.