### Getting Started with Client Source: https://github.com/e2b-dev/openapi-python-client/blob/main/end_to_end_tests/docstrings-on-attributes-golden-record/README.md Shows how to initialize the basic client for making requests to the API. ```APIDOC ## Client Initialization ### Description Initialize the client to interact with the API. The `base_url` is required. ### Method Instantiation ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from my_test_api_client import Client client = Client(base_url="https://api.example.com") ``` ### Response #### Success Response (200) N/A (Initialization doesn't return a response) #### Response Example N/A ``` -------------------------------- ### Install openapi-python-client with pip Source: https://github.com/e2b-dev/openapi-python-client/blob/main/README.md Installs the openapi-python-client package using standard pip. This is an alternative installation method if pipx is not preferred. ```bash pip install openapi-python-client ``` -------------------------------- ### Build and Install openapi-python-client Wheel without Poetry Source: https://github.com/e2b-dev/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md This snippet covers building a wheel distribution of the openapi-python-client and then installing it into a project that does not use Poetry. This is useful for integrating the client into existing non-Poetry projects. ```shell poetry build -f wheel pip install ``` -------------------------------- ### Paths Object Example in YAML Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md An example showcasing the Paths Object structure using YAML syntax. It mirrors the JSON example, illustrating a 'get' operation for the '/pets' path and its associated response details. ```yaml /pets: get: description: Returns all pets from the system that the user has access to responses: '200': description: A list of pets. content: application/json: schema: type: array items: $ref: '#/components/schemas/pet' ``` -------------------------------- ### Media Type Examples (JSON) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates how to provide JSON media type examples for a schema, including direct values and references to external examples. ```APIDOC ## Media Type Examples (JSON) ### Description This section illustrates how to specify examples for `application/json` content within an OpenAPI specification. It includes inline examples for different pet types and a reference to an external example for a frog. ### Method N/A (Schema definition) ### Endpoint N/A (Schema definition) ### Parameters N/A ### Request Body N/A ### Request Example ```json { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" }, "examples": { "cat": { "summary": "An example of a cat", "value": { "name": "Fluffy", "petType": "Cat", "color": "White", "gender": "male", "breed": "Persian" } }, "dog": { "summary": "An example of a dog with a cat's name", "value": { "name": "Puma", "petType": "Dog", "color": "Black", "gender": "Female", "breed": "Mixed" } }, "frog": { "$ref": "#/components/examples/frog-example" } } } } ``` ### Response N/A (Schema definition) ### Response Example N/A ``` -------------------------------- ### OpenAPI Parameter Examples (YAML) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates how to define examples for a query parameter named 'zipCode' in an OpenAPI specification. This includes referencing a shared example definition. ```yaml parameters: - name: 'zipCode' in: 'query' schema: type: 'string' format: 'zip-code' examples: zip-example: $ref: '#/components/examples/zip-example' ``` -------------------------------- ### Parameter Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Examples demonstrating different types of parameters: header, path, and query. ```APIDOC ## GET /users/{username} ### Description Retrieves user information based on the provided username. ### Method GET ### Endpoint `/users/{username}` ### Parameters #### Path Parameters - **username** (string) - Required - The username of the user to fetch. #### Query Parameters - **id** (array[string]) - Optional - The IDs of the objects to fetch. This parameter can be repeated. ### Request Example ``` GET /users/johndoe?id=123&id=456 ``` ### Response #### Success Response (200) - **user** (object) - Details of the user. #### Response Example ```json { "user": { "id": "johndoe123", "name": "John Doe" } } ``` ``` ```APIDOC ## POST /data ### Description Submits data to be processed. ### Method POST ### Endpoint `/data` ### Parameters #### Query Parameters - **freeForm** (object) - Optional - Allows for undefined query parameters where keys are strings and values are integers. ### Request Body - **description** (string) - Optional - A brief description of the request body. - **content** (map[string, object]) - Required - Defines the content of the request body, keyed by media type. - **required** (boolean) - Optional - Determines if the request body is required. ### Request Example ```json { "description": "This is a sample request body.", "content": { "application/json": { "schema": { "type": "object", "required": [ "lat", "long" ], "properties": { "lat": { "type": "number" }, "long": { "type": "number" } } } } }, "required": true } ``` ### Response #### Success Response (200) - **status** (string) - The status of the request. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Path Item Object Example in YAML Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates the Path Item Object using YAML syntax, detailing a 'get' operation, its responses, and parameters for API documentation. ```yaml get: description: Returns pets based on ID summary: Find pets by ID operationId: getPetsById responses: '200': description: pet response content: '*/*' : schema: type: array items: $ref: '#/components/schemas/Pet' default: description: error payload content: 'text/html': schema: $ref: '#/components/schemas/ErrorModel' parameters: - name: id in: path description: ID of pet to use required: true schema: type: array items: type: string style: simple ``` -------------------------------- ### YAML Media Type Example for Pet Schema Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Illustrates the 'application/json' media type using YAML syntax in an OpenAPI specification. This example includes schema references and sample data for pet objects, showcasing inline examples and referencing external examples. ```yaml application/json: schema: $ref: "#/components/schemas/Pet" examples: cat: summary: An example of a cat value: name: Fluffy petType: Cat color: White gender: male breed: Persian dog: summary: An example of a dog with a cat's name value: name: Puma petType: Dog color: Black gender: Female breed: Mixed frog: $ref: "#/components/examples/frog-example" ``` -------------------------------- ### Paths Object Example in JSON Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md An example demonstrating the structure of the Paths Object in JSON format, detailing a 'get' operation for a '/pets' path. This shows how to define operations, their descriptions, and response schemas. ```json { "/pets": { "get": { "description": "Returns all pets from the system that the user has access to", "responses": { "200": { "description": "A list of pets.", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/pet" } } } } } } } } } ``` -------------------------------- ### Schema Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides examples of different OpenAPI Schema Object configurations, including primitive types, simple models, map/dictionary properties, and models with examples. ```APIDOC ## Schema Object Examples ### Primitive Sample ```json { "type": "string", "format": "email" } ``` ```yaml type: string format: email ``` ### Simple Model ```json { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "address": { "$ref": "#/components/schemas/Address" }, "age": { "type": "integer", "format": "int32", "minimum": 0 } } } ``` ```yaml type: object required: - name properties: name: type: string address: $ref: '#/components/schemas/Address' age: type: integer format: int32 minimum: 0 ``` ### Model with Map/Dictionary Properties **String to String Mapping:** ```json { "type": "object", "additionalProperties": { "type": "string" } } ``` ```yaml type: object additionalProperties: type: string ``` **String to Model Mapping:** ```json { "type": "object", "additionalProperties": { "$ref": "#/components/schemas/ComplexModel" } } ``` ```yaml type: object additionalProperties: $ref: '#/components/schemas/ComplexModel' ``` ### Model with Example ```json { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } }, "required": [ "name" ], "example": { "name": "Puma", "id": 1 } } ``` ```yaml type: object properties: id: type: integer format: int64 name: type: string required: - name example: name: Puma id: 1 ``` ``` -------------------------------- ### Define Examples for JSON Request Body (OpenAPI) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This example illustrates how to define multiple examples for a JSON request body within an OpenAPI specification. It includes named examples with 'summary' and 'value' properties. ```yaml requestBody: content: 'application/json': schema: $ref: '#/components/schemas/Address' examples: foo: summary: A foo example value: {"foo": "bar"} bar: summary: A bar example value: {"bar": "baz"} ``` -------------------------------- ### Install tab completion for openapi-python-client Source: https://github.com/e2b-dev/openapi-python-client/blob/main/README.md Installs shell tab completion for the openapi-python-client command-line tool. This enhances usability by providing context-aware suggestions when typing commands. ```bash openapi-python-client --install-completion ``` -------------------------------- ### Install openapi-python-client with pipx Source: https://github.com/e2b-dev/openapi-python-client/blob/main/README.md Installs the openapi-python-client package and its dependencies using pipx, ensuring a clean environment. The `--include-deps` option also makes the `ruff` tool available for code cleanup. ```bash pipx install openapi-python-client --include-deps ``` -------------------------------- ### JSON Media Type Examples for Pet Schema Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This snippet demonstrates how to define media type examples for the 'application/json' content type in OpenAPI, referencing a 'Pet' schema and providing example values for different pets like cats and dogs. It also shows how to reference external examples. ```json { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" }, "examples": { "cat" : { "summary": "An example of a cat", "value": { "name": "Fluffy", "petType": "Cat", "color": "White", "gender": "male", "breed": "Persian" } }, "dog": { "summary": "An example of a dog with a cat's name", "value" : { "name": "Puma", "petType": "Dog", "color": "Black", "gender": "Female", "breed": "Mixed" }, "frog": { "$ref": "#/components/examples/frog-example" } } } } } ``` -------------------------------- ### YAML Media Type Examples for Pet Schema Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This snippet illustrates how to define media type examples using YAML for the 'application/json' content type in OpenAPI. It mirrors the JSON example by referencing a 'Pet' schema and providing specific examples for cat and dog, along with a reference to an external frog example. ```yaml application/json: schema: $ref: "#/components/schemas/Pet" examples: cat: summary: An example of a cat value: name: Fluffy petType: Cat color: White gender: male breed: Persian dog: summary: An example of a dog with a cat's name value: name: Puma petType: Dog color: Black gender: Female breed: Mixed frog: $ref: "#/components/examples/frog-example" ``` -------------------------------- ### Info Object Example in JSON Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This JSON example demonstrates the structure of the Info Object, including title, description, terms of service, contact details, license information, and version. ```json { "title": "Sample Pet Store App", "description": "This is a sample server for a pet store.", "termsOfService": "http://example.com/terms/", "contact": { "name": "API Support", "url": "http://www.example.com/support", "email": "support@example.com" }, "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0.1" } ``` -------------------------------- ### Example Object Usage Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Demonstrates how the Example Object can be used to provide sample data for request bodies, query parameters, and responses across different media types. ```APIDOC ## Example Object Usage ### Request Body Examples Examples can be provided for different media types within the `content` object of a request body. - **Type**: `object` - **Schema**: Reference to the schema of the example (`#/components/schemas/Address`) - **Examples**: A map of example names to their definitions. - **foo** (`object`): A simple JSON object example (`{"foo": "bar"}`). - **bar** (`object`): Another JSON object example (`{"bar": "baz"}`). - **xmlExample** (`object`): An example defined by an external XML file (`http://example.org/examples/address-example.xml`). - **textExample** (`string`): An example defined by an external text file (`http://foo.bar/examples/address-example.txt`). ```yaml requestBody: content: 'application/json': schema: $ref: '#/components/schemas/Address' examples: foo: summary: A foo example value: {"foo": "bar"} bar: summary: A bar example value: {"bar": "baz"} 'application/xml': examples: xmlExample: summary: This is an example in XML externalValue: 'http://example.org/examples/address-example.xml' 'text/plain': examples: textExample: summary: This is a text example externalValue: 'http://foo.bar/examples/address-example.txt' ``` ### Parameter Examples Examples can also be associated with parameters, typically using a `$ref` to a shared Example Object. - **Name**: `zipCode` - **In**: `query` - **Schema**: `string` with `zip-code` format. - **Examples**: A map of example names to their definitions. - **zip-example**: A reference to a shared example object (`#/components/examples/zip-example`). ```yaml parameters: - name: 'zipCode' in: 'query' schema: type: 'string' format: 'zip-code' examples: zip-example: $ref: '#/components/examples/zip-example' ``` ### Response Examples Examples for successful responses can be defined within the response object, specifying the media type and example details. - **Status Code**: `200` - **Description**: "your car appointment has been booked" - **Content**: `application/json` - **Schema**: Reference to the success response schema (`#/components/schemas/SuccessResponse`). - **Examples**: A map of example names to their definitions. - **confirmation-success**: A reference to a shared example object (`#/components/examples/confirmation-success`). ```yaml responses: '200': description: your car appointment has been booked content: application/json: schema: $ref: '#/components/schemas/SuccessResponse' examples: confirmation-success: $ref: '#/components/examples/confirmation-success' ``` ``` -------------------------------- ### OpenAPI Response Examples (YAML) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Shows how to define examples for a successful response (HTTP 200) in an OpenAPI specification, referencing a schema and a shared example definition for JSON content. ```yaml responses: '200': description: your car appointment has been booked content: application/json: schema: $ref: '#/components/schemas/SuccessResponse' examples: confirmation-success: $ref: '#/components/examples/confirmation-success' ``` -------------------------------- ### HTTP Request Example for Runtime Expressions Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md An example HTTP POST request used to illustrate how runtime expressions evaluate in the context of a callback operation. ```http POST /subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning HTTP/1.1 Host: example.org Content-Type: application/json Content-Length: 187 { "failedUrl" : "https://clientdomain.com/failed", "successUrls" : [ "https://clientdomain.com/fast", "https://clientdomain.com/medium", "https://clientdomain.com/slow" ] } 201 Created Location: https://example.org/subscription/1 ``` -------------------------------- ### Response Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Examples demonstrating different response types including arrays of complex objects, simple strings, and responses with headers. ```APIDOC ## Response Object Examples ### Response with Array of Complex Type This example shows how to define a response that returns an array of a complex object type. **Method:** Not specified (typically part of an operation) **Endpoint:** Not specified #### Response Body Schema - **type**: `array` - **items**: `$ref: '#/components/schemas/VeryComplexType'` #### Response Example (JSON) ```json { "description": "A complex object array response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/VeryComplexType" } } } } } ``` ### Response with Simple String Type This example defines a response that returns a plain text string. **Method:** Not specified **Endpoint:** Not specified #### Response Body Schema - **type**: `string` #### Response Example (JSON) ```json { "description": "A simple string response", "content": { "text/plain": { "schema": { "type": "string" } } } } ``` ### Response with String and Headers This example shows a string response that also includes rate limiting headers. **Method:** Not specified **Endpoint:** Not specified #### Response Body Schema - **type**: `string` - **example**: `"whoa!"` #### Response Headers - **X-Rate-Limit-Limit** (integer) - The number of allowed requests in the current period - **X-Rate-Limit-Remaining** (integer) - The number of remaining requests in the current period - **X-Rate-Limit-Reset** (integer) - The number of seconds left in the current period #### Response Example (JSON) ```json { "description": "A simple string response", "content": { "text/plain": { "schema": { "type": "string", "example": "whoa!" } } }, "headers": { "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", "schema": { "type": "integer" } }, "X-Rate-Limit-Remaining": { "description": "The number of remaining requests in the current period", "schema": { "type": "integer" } }, "X-Rate-Limit-Reset": { "description": "The number of seconds left in the current period", "schema": { "type": "integer" } } } } ``` ### Response with No Return Value This defines a response indicating successful creation with no specific return body. **Method:** Not specified **Endpoint:** Not specified #### Response Example (JSON) ```json { "description": "object created" } ``` ``` -------------------------------- ### License Object Example (JSON and YAML) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows examples of the License object, detailing the terms under which the API is licensed. It includes options for license name, identifier, or URL, presented in JSON and YAML. ```json { "name": "Apache 2.0", "identifier": "Apache-2.0" } ``` ```yaml name: Apache 2.0 identifier: Apache-2.0 ``` -------------------------------- ### Info Object Example in YAML Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML example illustrates the same Info Object structure as the JSON example, showing how API metadata like title, description, and contact can be represented. ```yaml title: Sample Pet Store App description: This is a sample server for a pet store. termsOfService: http://example.com/terms/ contact: name: API Support url: http://www.example.com/support email: support@example.com license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html version: 1.0.1 ``` -------------------------------- ### Path Item Object Example in JSON Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Demonstrates the structure of a Path Item Object in JSON format, defining a 'get' operation with responses and parameters for an API. ```json { "get": { "description": "Returns pets based on ID", "summary": "Find pets by ID", "operationId": "getPetsById", "responses": { "200": { "description": "pet response", "content": { "*/*": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Pet" } } } } }, "default": { "description": "error payload", "content": { "text/html": { "schema": { "$ref": "#/components/schemas/ErrorModel" } } } } } }, "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to use", "required": true, "schema": { "type": "array", "items": { "type": "string" } }, "style": "simple" } ] } ``` -------------------------------- ### Example OpenAPI Key Names Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates valid examples of key names that conform to the OpenAPI specification's regular expression for component keys. These examples demonstrate the allowed characters and formats for keys used in mapping reusable OpenAPI objects. ```text User User_1 User_Name user-name my.org.User ``` -------------------------------- ### Call API Endpoint (Synchronous) - Python Source: https://github.com/e2b-dev/openapi-python-client/blob/main/integration-tests/README.md Make a synchronous API call to retrieve data using the client. This example demonstrates fetching a MyDataModel and getting detailed response information. ```python from integration_tests.models import MyDataModel from integration_tests.api.my_tag import get_my_data_model from integration_tests.types import Response with client as client: my_data: MyDataModel = get_my_data_model.sync(client=client) response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) ``` -------------------------------- ### Tag Object Example (YAML) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Shows a Tag Object example using YAML syntax, specifying the tag name and its associated description. ```yaml name: pet description: Pets operations ``` -------------------------------- ### Server Object Example (Single) - JSON and YAML Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Example of a Server object, representing a server where the API is available. This includes the URL and an optional description. Shown in JSON and YAML. ```json { "url": "https://development.gigantic-server.com/v1", "description": "Development server" } ``` ```yaml url: https://development.gigantic-server.com/v1 description: Development server ``` -------------------------------- ### JSON Media Type Example for Pet Schema Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates the 'application/json' media type within an OpenAPI specification, including schema references and example values for different pet types (cat, dog, frog). It shows how to define inline examples and reference external ones. ```json { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" }, "examples": { "cat" : { "summary": "An example of a cat", "value": { "name": "Fluffy", "petType": "Cat", "color": "White", "gender": "male", "breed": "Persian" } }, "dog": { "summary": "An example of a dog with a cat's name", "value" : { "name": "Puma", "petType": "Dog", "color": "Black", "gender": "Female", "breed": "Mixed" } }, "frog": { "$ref": "#/components/examples/frog-example" } } } } ``` -------------------------------- ### Example Object Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Defines the structure for example objects, used to provide literal or external examples for API request or response payloads. ```APIDOC ## Example Object ### Description An object used to provide examples of an API request or response payload. ### Fields - **summary** (string) - Short description for the example. - **description** (string) - Long description for the example. CommonMark syntax MAY be used for rich text representation. - **value** (Any) - Embedded literal example. This field is mutually exclusive with `externalValue`. - **externalValue** (string) - A URL that points to the literal example. This field is mutually exclusive with `value`. ### Notes - The `value` field and `externalValue` field are mutually exclusive. - For media types not easily represented in JSON or YAML, use a string value in the `value` field to contain the example, escaping where necessary. - Tooling implementations MAY validate compatibility of the example value with the associated type schema. ``` -------------------------------- ### Server Object Example (Multiple) - JSON and YAML Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Example demonstrating how to describe multiple servers for an API using the 'servers' array. This illustrates different environments like development, staging, and production. Shown in JSON and YAML. ```json { "servers": [ { "url": "https://development.gigantic-server.com/v1", "description": "Development server" }, { "url": "https://staging.gigantic-server.com/v1", "description": "Staging server" }, { "url": "https://api.gigantic-server.com/v1", "description": "Production server" } ] } ``` ```yaml servers: - url: https://development.gigantic-server.com/v1 description: Development server - url: https://staging.gigantic-server.com/v1 description: Staging server - url: https://api.gigantic-server.com/v1 description: Production server ``` -------------------------------- ### Security Scheme Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Examples of how to define different security schemes in JSON and YAML formats. ```APIDOC ## Security Scheme Object Examples ### Basic Authentication Sample #### JSON ```json { "type": "http", "scheme": "basic" } ``` #### YAML ```yaml type: http scheme: basic ``` ### API Key Sample #### JSON ```json { "type": "apiKey", "name": "api_key", "in": "header" } ``` #### YAML ```yaml type: apiKey name: api_key in: header ``` ### JWT Bearer Sample #### JSON ```json { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } ``` #### YAML ```yaml type: http scheme: bearer bearerFormat: JWT ``` ### Implicit OAuth2 Sample #### JSON ```json { "type": "oauth2", "flows": { "implicit": { "authorizationUrl": "https://example.com/api/oauth/dialog", "scopes": { "write:pets": "modify pets in your account", "read:pets": "read your pets" } } } } ``` #### YAML ```yaml type: oauth2 flows: implicit: authorizationUrl: https://example.com/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets ``` ``` -------------------------------- ### Synchronous API Call Source: https://github.com/e2b-dev/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Demonstrates how to make a synchronous (blocking) API call to fetch data. It shows how to retrieve parsed data directly or get detailed response information including status codes. ```python from my_test_api_client.models import MyDataModel from my_test_api_client.api.my_tag import get_my_data_model from my_test_api_client.types import Response with client as client: my_data: MyDataModel = get_my_data_model.sync(client=client) # or if you need more info (e.g. status_code) response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client) ``` -------------------------------- ### Define Examples for Plain Text Request Body (OpenAPI) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This example shows how to define a plain text example for a request body in an OpenAPI specification, utilizing 'externalValue' to link to an external text file. ```yaml requestBody: content: 'text/plain': examples: textExample: summary: This is a text example externalValue: 'https://foo.bar/examples/address-example.txt' ``` -------------------------------- ### Schema Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides examples of Schema Objects for primitive types and simple models. ```APIDOC ## Schema Object Examples ### Description Provides examples for defining primitive types and simple models using the Schema Object. ### Method N/A (Schema Examples) ### Endpoint N/A (Schema Examples) ### Parameters None ### Request Example #### Primitive Sample (JSON) ```json { "type": "string", "format": "email" } ``` #### Primitive Sample (YAML) ```yaml type: string format: email ``` #### Simple Model (JSON) ```json { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "address": { "$ref": "#/components/schemas/Address" }, "age": { "type": "integer", "format": "int32", "minimum": 0 } } } ``` #### Simple Model (YAML) ```yaml type: object required: - name properties: name: type: string address: $ref: '#/components/schemas/Address' age: type: integer format: int32 minimum: 0 ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Request Body Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Examples of request bodies, including referenced models and different content types. ```APIDOC ## Request Body Examples ### Description A request body with a referenced model definition. ### Method POST ### Endpoint /api/users ### Parameters #### Request Body - **description** (string) - Description of the user to add. - **content** (object) - Contains schema and examples for different media types. - **application/json** (object) - **schema** ([Schema Object](#schemaObject) | [Reference Object](#referenceObject)) - The schema defining the content. - **examples** (Map[string, [Example Object](#exampleObject) | [Reference Object](#referenceObject)]) - Examples of the media type. - **application/xml** (object) - **schema** ([Schema Object](#schemaObject) | [Reference Object](#referenceObject)) - The schema defining the content. - **examples** (Map[string, [Example Object](#exampleObject) | [Reference Object](#referenceObject)]) - Examples of the media type. - **text/plain** (object) - **examples** (Map[string, [Example Object](#exampleObject) | [Reference Object](#referenceObject)]) - Examples of the media type. - ***/* ** (object) - **examples** (Map[string, [Example Object](#exampleObject) | [Reference Object](#referenceObject)]) - Examples of the media type. ### Request Example ```json { "description": "user to add to the system", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" }, "examples": { "user" : { "summary": "User Example", "externalValue": "http://foo.bar/examples/user-example.json" } } }, "application/xml": { "schema": { "$ref": "#/components/schemas/User" }, "examples": { "user" : { "summary": "User example in XML", "externalValue": "http://foo.bar/examples/user-example.xml" } } }, "text/plain": { "examples": { "user" : { "summary": "User example in Plain text", "externalValue": "http://foo.bar/examples/user-example.txt" } } }, "*/*": { "examples": { "user" : { "summary": "User example in other format", "externalValue": "http://foo.bar/examples/user-example.whatever" } } } } } ``` ### Response #### Success Response (200) - **message** (string) - Indicates success or failure. #### Response Example ```json { "message": "User added successfully." } ``` ``` -------------------------------- ### File Upload Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Examples demonstrating how to define file uploads in OpenAPI specifications, including base64 encoding, binary transfer, and specific media types. ```APIDOC ## File Uploads ### Description This section describes how file uploads are handled in OpenAPI, using schema types and formats for different transfer methods. ### Method N/A (Documentation of schema definitions) ### Endpoint N/A ### Parameters N/A #### Request Body ##### Base64 Encoded File Upload ```yaml requestBody: content: application/json: # Or other appropriate media type schema: type: string format: base64 ``` ##### Binary File Upload (Octet-Stream) ```yaml requestBody: content: application/octet-stream: schema: type: string format: binary ``` ##### Specific Media Type File Upload (e.g., JPEG, PNG) ```yaml requestBody: content: image/jpeg: schema: type: string format: binary image/png: schema: type: string format: binary ``` ##### Multiple File Upload (Multipart Form Data) ```yaml requestBody: content: multipart/form-data: schema: type: object properties: file: type: array items: type: string format: binary ``` ### Request Example N/A (These are schema definitions, not specific request examples) ### Response N/A ``` -------------------------------- ### OpenAPI Operation Object Example (YAML) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This snippet shows an example of an OpenAPI Operation Object in YAML format. It mirrors the JSON example, detailing an API operation's metadata, parameters, request body, responses, and security. ```yaml tags: - pet summary: Updates a pet in the store with form data operationId: updatePetWithForm parameters: - name: petId in: path description: ID of pet that needs to be updated required: true schema: type: string requestBody: content: 'application/x-www-form-urlencoded': schema: type: object properties: name: description: Updated name of the pet type: string status: description: Updated status of the pet type: string required: - status responses: '200': description: Pet updated. content: 'application/json': {} 'application/xml': {} '405': description: Method Not Allowed content: 'application/json': {} 'application/xml': {} security: - petstore_auth: - write:pets - read:pets ``` -------------------------------- ### Callback Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Examples demonstrating the use of callback objects to define webhook callbacks, including dynamic URL generation based on runtime expressions. ```APIDOC ## Callback Object Examples ### myCallback This example uses the user-provided `queryUrl` query string parameter to define the callback URL. It demonstrates how to use a callback object to describe a WebHook callback associated with a subscription operation. ### Method POST ### Endpoint `{$request.query.queryUrl}` ### Request Body #### Request Body Schema ```yaml requestBody: description: Callback payload content: 'application/json': schema: $ref: '#/components/schemas/SomePayload' ``` ### Response #### Success Response (200) - **description** (string) - callback successfully processed ### transactionCallback This example shows a callback where the server is hard-coded, but the query string parameters are populated from the `id` and `email` properties in the request body. ### Method POST ### Endpoint `http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}` ### Request Body #### Request Body Schema ```yaml requestBody: description: Callback payload content: 'application/json': schema: $ref: '#/components/schemas/SomePayload' ``` ### Response #### Success Response (200) - **description** (string) - callback successfully processed ``` -------------------------------- ### OpenAPI Request Body Examples (YAML) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Demonstrates how to define various examples for a request body in different content types (JSON, XML, text/plain) within an OpenAPI specification. These examples aid in understanding the expected structure and values for requests. ```yaml requestBody: content: 'application/json': schema: $ref: '#/components/schemas/Address' examples: foo: summary: A foo example value: {"foo": "bar"} bar: summary: A bar example value: {"bar": "baz"} 'application/xml': examples: xmlExample: summary: This is an example in XML externalValue: 'http://example.org/examples/address-example.xml' 'text/plain': examples: textExample: summary: This is a text example externalValue: 'http://foo.bar/examples/address-example.txt' ``` -------------------------------- ### OAuth Flow Object Examples Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides examples of the OAuth Flow Object in JSON and YAML. ```APIDOC ## OAuth Flow Object Examples ### JSON ```json { "type": "oauth2", "flows": { "implicit": { "authorizationUrl": "https://example.com/api/oauth/dialog", "scopes": { "write:pets": "modify pets in your account", "read:pets": "read your pets" } }, "authorizationCode": { "authorizationUrl": "https://example.com/api/oauth/dialog", "tokenUrl": "https://example.com/api/oauth/token", "scopes": { "write:pets": "modify pets in your account", "read:pets": "read your pets" } } } } ``` ### YAML ```yaml type: oauth2 flows: implicit: authorizationUrl: https://example.com/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets authorizationCode: authorizationUrl: https://example.com/api/oauth/dialog tokenUrl: https://example.com/api/oauth/token scopes: write:pets: modify pets in your account read:pets: read your pets ``` ``` -------------------------------- ### Server Object Example (with Variables) - JSON and YAML Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Example of a Server object utilizing variables for URL templating, allowing for dynamic server configurations like different usernames or ports. Shown in JSON and YAML. ```json { "servers": [ { "url": "https://{username}.gigantic-server.com:{port}/{basePath}", "description": "The production API server", "variables": { "username": { "default": "demo", "description": "this value is assigned by the service provider, in this example `gigantic-server.com`" }, "port": { "enum": [ "8443", "443" ], "default": "8443" }, "basePath": { "default": "v2" } } } ] } ``` ```yaml servers: - url: https://{username}.gigantic-server.com:{port}/{basePath} description: The production API server variables: username: default: demo description: this value is assigned by the service provider, in this example `gigantic-server.com` port: enum: - '8443' - '443' default: '8443' basePath: default: v2 ``` -------------------------------- ### Tag Object Example (JSON) Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides an example of a Tag Object in JSON, defining a tag with a name and description for grouping operations. ```json { "name": "pet", "description": "Pets operations" } ``` -------------------------------- ### Server Object Example Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This example snippet defines a Server object, which specifies the URL of a target server and an optional description. This is crucial for indicating where API requests should be sent. ```json { "url": "https://api.example.com/{version}", "description": "Production server" } ``` -------------------------------- ### Example Media Type Definitions - OpenAPI Source: https://github.com/e2b-dev/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides examples of media type definitions commonly used within OpenAPI specifications. These adhere to RFC6838 for standard media type formatting. ```plaintext text/plain; charset=utf-8 application/json application/vnd.github+json application/vnd.github.v3+json application/vnd.github.v3.raw+json application/vnd.github.v3.text+json application/vnd.github.v3.html+json application/vnd.github.v3.full+json application/vnd.github.v3.diff application/vnd.github.v3.patch ```