### OpenAPI Paths Object Example - YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md An example of the OpenAPI Paths Object in YAML format, demonstrating a definition for the '/pets' path with a GET operation, including response schema definition. ```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' ``` -------------------------------- ### Defining Parameter Examples in OpenAPI (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Shows how to define examples for a parameter in an OpenAPI specification. This example uses a $ref to reference an example defined in the components section. ```yaml parameters: - name: 'zipCode' in: 'query' schema: type: 'string' format: 'zip-code' examples: zip-example: $ref: '#/components/examples/zip-example' ``` -------------------------------- ### Installing openapi-python-client with pipx (including dependencies) Source: https://github.com/benchling/openapi-python-client/blob/main/README.md Recommends installing the `openapi-python-client` tool using `pipx` to avoid package conflicts. The `--include-deps` flag ensures that dependencies like `ruff` are also installed and available in the path for post-generation code cleanup. ```bash pipx install openapi-python-client --include-deps ``` -------------------------------- ### Installing openapi-python-client with pip Source: https://github.com/benchling/openapi-python-client/blob/main/README.md Provides an alternative installation method using the standard `pip` package manager. This is a simpler installation but does not automatically handle dependencies like `ruff` for post-generation hooks. ```bash pip install openapi-python-client ``` -------------------------------- ### OpenAPI Paths Object Example - JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md An example of the OpenAPI Paths Object in JSON format, demonstrating a definition for the '/pets' path with a GET operation, including response schema definition. ```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" } } } } } } } } } ``` -------------------------------- ### Example Info Object (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides a concrete example of an OpenAPI Info Object in YAML format, illustrating the required title and version fields, and optional fields like description, termsOfService, contact, and license. This is an alternative representation of the JSON example. ```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 ``` -------------------------------- ### Defining Media Type Examples in OpenAPI (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML snippet provides an equivalent definition to the JSON example, showing how to define examples for the `application/json` media type in an OpenAPI specification using YAML syntax. It includes inline examples ('cat', 'dog') and a reference ('frog') to an external 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" ``` -------------------------------- ### Using Example Object in Request Body (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Illustrates how to include multiple inline (`foo`, `bar`) and external (`xmlExample`, `textExample`) examples for different media types (`application/json`, `application/xml`, `text/plain`) within an OpenAPI request body definition using the Example Object. ```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: 'https://example.org/examples/address-example.xml' 'text/plain': examples: textExample: summary: This is a text example externalValue: 'https://foo.bar/examples/address-example.txt' ``` -------------------------------- ### Defining Media Type Examples in OpenAPI (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This JSON snippet demonstrates how to define examples for a specific media type (`application/json`) within an OpenAPI specification. It shows inline examples ('cat', 'dog') with summaries and values, and a reference ('frog') to an external example definition. ```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 Paths Object in JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates a simple OpenAPI Paths Object defining a '/pets' endpoint with a GET operation, showing the response structure for a 200 status code. ```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" } } } } } } } } } ``` -------------------------------- ### Installing Development Dependencies with PDM Source: https://github.com/benchling/openapi-python-client/blob/main/CONTRIBUTING.md Use this command in the project directory to install all necessary development dependencies into a virtual environment using PDM. This sets up the environment required for development and testing. ```Shell pdm install ``` -------------------------------- ### Using Example Object in Parameter (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides an example of referencing a shared Example Object definition (`#/components/examples/zip-example`) for a query parameter (`zipCode`) within an OpenAPI specification. ```yaml parameters: - name: 'zipCode' in: 'query' schema: type: 'string' format: 'zip-code' examples: zip-example: $ref: '#/components/examples/zip-example' ``` -------------------------------- ### Example Paths Object in YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates the same simple OpenAPI Paths Object defining a '/pets' endpoint with a GET operation, showing the response structure for a 200 status code, but in YAML format. ```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' ``` -------------------------------- ### Install Local Package with Pip Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/test-3-1-golden-record/README.md Build a wheel file for the package and then install it using pip in a project that does not use Poetry. ```Shell poetry build -f wheel ``` ```Shell pip install ``` -------------------------------- ### Defining Response Examples in OpenAPI (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Demonstrates how to define examples for a specific response status code and content type within an OpenAPI specification. This example uses a $ref to reference an example defined in the components section. ```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' ``` -------------------------------- ### Example Info Object (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides a concrete example of an OpenAPI Info Object in JSON format, illustrating the required title and version fields, and optional fields like description, termsOfService, contact, and license. ```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" } ``` -------------------------------- ### Installing Tab Completion for openapi-python-client Source: https://github.com/benchling/openapi-python-client/blob/main/README.md Installs shell tab completion for the `openapi-python-client` command-line tool. This enhances usability by providing suggestions for commands and arguments when typing in the terminal. ```bash openapi-python-client --install-completion ``` -------------------------------- ### OpenAPI Path Item Object Example (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML snippet provides the same example as the JSON version, illustrating an OpenAPI Path Item Object with a GET operation. It specifies the operation details, defines the 200 success and default error responses, and includes the required path parameter 'id'. ```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 ``` -------------------------------- ### Example Parameter Values for OpenAPI Styles Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Illustrates example values for string, array, and object parameter types used to demonstrate different OpenAPI style renderings in the subsequent table. ```Conceptual string -> "blue" array -> ["blue","black","brown"] object -> { "R": 100, "G": 200, "B": 150 } ``` -------------------------------- ### OpenAPI Tag Object Example (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides a YAML example demonstrating the structure of a Tag Object in OpenAPI, including its name and description. ```yaml name: pet description: Pets operations ``` -------------------------------- ### Defining Media Type Examples OpenAPI JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows how to define media type examples for a schema in OpenAPI using JSON. It includes inline examples for 'cat' and 'dog' and a reference example for 'frog'. This structure is used within a Media Type Object. ```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" } } } } } ``` -------------------------------- ### Defining an Object Schema with Example - OpenAPI Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This snippet defines an OpenAPI Schema Object for an object model including property definitions, required fields, and an example object. The `example` keyword provides a sample instance that conforms to the defined schema, useful for documentation and testing. ```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 ``` -------------------------------- ### Defining Media Type Examples OpenAPI YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates defining media type examples for a schema in OpenAPI using YAML. It provides inline examples for 'cat' and 'dog' and a reference example for 'frog', mirroring the JSON structure. This is typically found within a Media Type Object. ```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" ``` -------------------------------- ### OpenAPI Tag Object Example (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides a JSON example demonstrating the structure of a Tag Object in OpenAPI, including its name and description. ```json { "name": "pet", "description": "Pets operations" } ``` -------------------------------- ### Install Local Wheel File with Pip Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Installs a package from a local wheel file using pip, useful when the target project does not use Poetry. ```bash pip install ``` -------------------------------- ### OpenAPI Path Item Object Example (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This JSON snippet demonstrates an OpenAPI Path Item Object defining a GET operation. It includes details about the operation ID, summary, description, possible responses (200 success and default error), and a required path parameter 'id' for filtering pets. ```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" } ] } ``` -------------------------------- ### Installing Local Wheel Package with pip (Shell) Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/literal-enums-golden-record/README.md Installs a package from a local wheel (.whl) file using pip. This is used to install a package built locally without publishing it, into a project that doesn't use Poetry. ```Shell pip install ``` -------------------------------- ### Defining Request Body Examples in OpenAPI (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates how to define multiple examples for different content types within a request body definition in OpenAPI. It shows both inline JSON examples and external references for XML and text content. ```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' ``` -------------------------------- ### Using Example Object in Response (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows how to reference a shared Example Object definition (`#/components/examples/confirmation-success`) for a specific response (`200`) within an OpenAPI specification. ```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' ``` -------------------------------- ### Install Local Package with Poetry Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/test-3-1-golden-record/README.md Install the local package directly into another project that is also using Poetry for dependency management. ```Shell poetry add ``` -------------------------------- ### OpenAPI Header Object Example (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides a YAML example demonstrating the structure of a simple Header Object in OpenAPI, specifying its description and schema type as integer. ```yaml description: The number of allowed requests in the current period schema: type: integer ``` -------------------------------- ### Example OpenAPI Path Item Object (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This JSON snippet demonstrates the structure of an OpenAPI Path Item Object. It defines a GET operation ('getPetsById') with specific responses (200 and default) and a path parameter ('id'). The responses specify content types and schemas, referencing components. ```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" } }\n } } } }, "parameters": [ { "name": "id", "in": "path", "description": "ID of pet to use", "required": true, "schema": { "type": "array", "items": { "type": "string" } }, "style": "simple" } ] } ``` -------------------------------- ### HTTP Example for OpenAPI Callback Runtime Expressions Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md An example HTTP request and response used to illustrate how runtime expressions can extract values from the request and response for use in OpenAPI callback definitions. ```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 ``` -------------------------------- ### Examples of Media Types in OpenAPI Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This snippet provides examples of various media type strings that can be used within an OpenAPI document, following the conventions described in RFC6838. These examples illustrate common formats like plain text, JSON, and vendor-specific types. ```text 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 ``` -------------------------------- ### Operation Object Example - YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML object provides an example structure for an OpenAPI Operation Object, detailing parameters, request body, responses, and security for an endpoint that updates a pet using form data, mirroring the JSON example. ```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: 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 ``` -------------------------------- ### Example HTTP Request/Response for Runtime Expression Evaluation Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates a sample HTTP POST request and its response, used as the context for evaluating runtime expressions to dynamically determine callback URLs or access request/response details. ```HTTP POST /subscribe/myevent?queryUrl=http://clientdomain.com/stillrunning HTTP/1.1 Host: example.org Content-Type: application/json Content-Length: 187 { "failedUrl" : "http://clientdomain.com/failed", "successUrls" : [ "http://clientdomain.com/fast", "http://clientdomain.com/medium", "http://clientdomain.com/slow" ] } 201 Created Location: http://example.org/subscription/1 ``` -------------------------------- ### OpenAPI Header Object Example (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides a JSON example demonstrating the structure of a simple Header Object in OpenAPI, specifying its description and schema type as integer. ```json { "description": "The number of allowed requests in the current period", "schema": { "type": "integer" } } ``` -------------------------------- ### Example Header Object (integer type) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md A simple Header Object example defining a header of type 'integer'. It includes a description and the schema type. ```json { "description": "The number of allowed requests in the current period", "schema": { "type": "integer" } } ``` ```yaml description: The number of allowed requests in the current period schema: type: integer ``` -------------------------------- ### Example Parameter Values for Serialization Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides example values for string, array, and object data types that are used to illustrate the rendering differences across various OpenAPI parameter serialization styles. ```Data Representation string -> "blue" array -> ["blue","black","brown"] object -> { "R": 100, "G": 200, "B": 150 } ``` -------------------------------- ### Example OpenAPI Path Item Object (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This YAML snippet provides an alternative representation of the OpenAPI Path Item Object shown in JSON. It defines the same GET operation ('getPetsById') including responses (200 and default) and a path parameter ('id'), specifying content types and schemas with component references. ```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 ``` -------------------------------- ### Define Object Schema with Example (OpenAPI) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Defines an OpenAPI schema for an object with specific properties and required fields, including an `example` object to illustrate the expected structure and values. ```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 ``` -------------------------------- ### Relative Schema Document Example (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows how to use a Reference Object in YAML format to point to a schema defined in a separate, relative YAML file. This is the YAML equivalent of the JSON example. ```yaml $ref: Pet.yaml ``` -------------------------------- ### Build Wheel File with Poetry Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Builds a wheel distribution file (.whl) for the package, which can be installed by tools like pip. ```bash poetry build -f wheel ``` -------------------------------- ### Example OpenAPI Info Object (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates the structure of an OpenAPI Info Object in JSON format, including title, summary, description, terms of service, contact information, license details, and version. This object provides metadata about the API. ```json { "title": "Sample Pet Store App", "summary": "A pet store manager.", "description": "This is a sample server for a pet store.", "termsOfService": "https://example.com/terms/", "contact": { "name": "API Support", "url": "https://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 OpenAPI Info Object (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates the structure of an OpenAPI Info Object in YAML format, including title, summary, description, terms of service, contact information, license details, and version. This object provides metadata about the API. ```yaml title: Sample Pet Store App summary: A pet store manager. description: This is a sample server for a pet store. termsOfService: https://example.com/terms/ contact: name: API Support url: https://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 Media Types in OpenAPI Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This snippet provides examples of valid media type strings that can be used within an OpenAPI definition, conforming to RFC6838. ```text 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 ``` -------------------------------- ### Example Reference Object Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md A simple example of a Reference Object using the '$ref' field to point to another component within the specification, specifically a schema named 'Pet'. ```json { "$ref": "#/components/schemas/Pet" } ``` ```yaml $ref: '#/components/schemas/Pet' ``` -------------------------------- ### Example Tag Object Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md An example of a Tag Object used to add metadata to a tag. It includes the required 'name' field and an optional 'description'. ```json { "name": "pet", "description": "Pets operations" } ``` ```yaml name: pet description: Pets operations ``` -------------------------------- ### Example Relative Schema Document Reference Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md An example of a Reference Object using '$ref' to reference a schema defined in a separate, relative document. ```json { "$ref": "Pet.json" } ``` ```yaml $ref: Pet.yaml ``` -------------------------------- ### Example Valid Keys for Components Object Fields Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Examples demonstrating valid key names for the reusable objects within the OpenAPI Components object, adhering to the `^[a-zA-Z0-9\.\-_]+$` regular expression pattern. ```Text User User_1 User_Name user-name my.org.User ``` -------------------------------- ### Operation Object Example - JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This JSON object provides an example structure for an OpenAPI Operation Object, detailing parameters, request body, responses, and security for an endpoint that updates a pet using form data. ```json { "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" ] } ] } ``` -------------------------------- ### Initializing Basic Client Python Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Demonstrates how to create a basic client instance for the my-test-api-client library using the `Client` class, specifying the base URL for the API. ```python from my_test_api_client import Client client = Client(base_url="https://api.example.com") ``` -------------------------------- ### External Documentation Object Example - YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML object illustrates the structure of an OpenAPI External Documentation Object, used to reference external resources for extended documentation, including a description and a required URL, mirroring the JSON example. ```yaml description: Find more info here url: https://example.com ``` -------------------------------- ### Defining Request Body with Referenced Schema and Examples (JSON/YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates how to define a request body in OpenAPI/Swagger using a referenced schema and providing multiple examples for different media types (application/json, application/xml, text/plain, */*). ```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" } } } } } ``` ```yaml 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 text plain format externalValue: 'http://foo.bar/examples/user-example.txt' '*/*': examples: user: summary: User example in other format externalValue: 'http://foo.bar/examples/user-example.whatever' ``` -------------------------------- ### Defining OpenAPI Components in YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML snippet provides an example of the OpenAPI `components` object, mirroring the JSON example. It shows how to define reusable schemas, parameters, responses, and security schemes using YAML syntax. This object is essential for creating a well-structured and reusable API specification. ```yaml components: schemas: GeneralError: type: object properties: code: type: integer format: int32 message: type: string Category: type: object properties: id: type: integer format: int64 name: type: string Tag: type: object properties: id: type: integer format: int64 name: type: string parameters: skipParam: name: skip in: query description: number of items to skip required: true schema: type: integer format: int32 limitParam: name: limit in: query description: max records to return required: true schema: type: integer format: int32 responses: NotFound: description: Entity not found. IllegalInput: description: Illegal input for operation. GeneralError: description: General Error content: application/json: schema: $ref: '#/components/schemas/GeneralError' securitySchemes: api_key: type: apiKey name: api_key in: header petstore_auth: type: oauth2 flows: implicit: authorizationUrl: http://example.org/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets ``` -------------------------------- ### Example: OpenAPI Response Object - No Content Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides an example of an OpenAPI Response Object definition for a response that indicates success but returns no content, typically used for operations like creation or deletion. ```json { "description": "object created" } ``` ```yaml description: object created ``` -------------------------------- ### Relative Schema Document Example (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows how to use a Reference Object to point to a schema defined in a separate, relative JSON file. This allows for modularizing OpenAPI definitions across multiple files. ```json { "$ref": "Pet.json" } ``` -------------------------------- ### Example OpenAPI License Object (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows the structure of an OpenAPI License Object in JSON format. This object specifies the license information for the API, including the license name and identifier (or URL). ```json { "name": "Apache 2.0", "identifier": "Apache-2.0" } ``` -------------------------------- ### Local Reference Object Example (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates a Reference Object using a local URI to point to a component within the same OpenAPI document. This is a common way to reuse schema definitions. ```json { "$ref": "#/components/schemas/Pet" } ``` -------------------------------- ### Example Payload Matching allOf Discriminator Mapping (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides a JSON payload example that matches the polymorphic schema structure defined using `allOf` and a discriminator with a `mapping`. The `petType` value "dog" matches the mapping entry, indicating the `Dog` schema should be used. ```json { "petType": "dog", "bark": "soft" } ``` -------------------------------- ### Building Wheel Package with Poetry (Shell) Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/literal-enums-golden-record/README.md Builds the package into a wheel (.whl) distribution file using Poetry. This format is suitable for installation with pip. ```Shell poetry build -f wheel ``` -------------------------------- ### Example OpenAPI License Object (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Shows the structure of an OpenAPI License Object in YAML format. This object specifies the license information for the API, including the license name and identifier (or URL). ```yaml name: Apache 2.0 identifier: Apache-2.0 ``` -------------------------------- ### Example Payload Matching allOf Discriminator (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides a JSON payload example that matches the polymorphic schema structure defined using `allOf` and a discriminator. The `petType` value "Cat" indicates the `Cat` schema should be used. ```json { "petType": "Cat", "name": "misty" } ``` -------------------------------- ### Example Payload Matching Discriminator (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Provides an example JSON payload that corresponds to the schema defined with a discriminator. The value of the `petType` property ("Cat") indicates which schema (`Cat`) should be used for validation and interpretation. ```json { "id": 12345, "petType": "Cat" } ``` -------------------------------- ### Initializing Authenticated Client Python Source: https://github.com/benchling/openapi-python-client/blob/main/integration-tests/README.md Shows how to create a client instance that includes authentication by providing a token during initialization. Use this client when the API requires authentication. ```python from integration_tests import AuthenticatedClient client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") ``` -------------------------------- ### Example OAuth2 Security Requirement in JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This JSON example demonstrates a Security Requirement Object for an OAuth2 scheme ('petstore_auth'). The value is an array listing the specific scopes ('write:pets', 'read:pets') required to satisfy this security requirement. ```json { "petstore_auth": [ "write:pets", "read:pets" ] } ``` -------------------------------- ### Relative Document with Embedded Schema Example (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Illustrates using a Reference Object in YAML format to point to a specific schema definition embedded within another relative YAML file. This is the YAML equivalent of the JSON example. ```yaml $ref: definitions.yaml#/Pet ``` -------------------------------- ### Example: OpenAPI Response Object - String with Headers Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Illustrates an OpenAPI Response Object definition for a plain text response that also includes definitions for custom rate-limiting headers. ```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" } } } } ``` ```yaml 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 ``` -------------------------------- ### Example Relative Document with Embedded Schema Reference Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md An example of a Reference Object using '$ref' to reference a specific schema ('Pet') embedded within another relative document ('definitions.json' or 'definitions.yaml'). ```json { "$ref": "definitions.json#/Pet" } ``` ```yaml $ref: definitions.yaml#/Pet ``` -------------------------------- ### Example OAuth2 Security Requirement in YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This YAML example shows an OAuth2 security requirement. It maps the security scheme name ('petstore_auth') to a list of required scopes ('write:pets', 'read:pets'), demonstrating how scopes are specified for OAuth2 security requirements. ```yaml petstore_auth: - write:pets - read:pets ``` -------------------------------- ### Initializing Basic Client Python Source: https://github.com/benchling/openapi-python-client/blob/main/integration-tests/README.md Demonstrates how to create a basic client instance for accessing the API. This client does not include built-in authentication. ```python from integration_tests import Client client = Client(base_url="https://api.example.com") ``` -------------------------------- ### Example OAuth2 Flow Object in JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This JSON example demonstrates the structure of an OAuth Flow Object within an OpenAPI security scheme. It shows configurations for both 'implicit' and 'authorizationCode' flows, including required URLs and defined scopes with descriptions. ```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" } } } } ``` -------------------------------- ### Example OpenAPI Responses Object (JSON/YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This example demonstrates defining an OpenAPI Responses Object. It includes a specific response for the `200` HTTP status code, detailing the successful payload structure, and a `default` response to handle other cases, typically errors, providing an error model schema. ```json { "200": { "description": "a pet to be returned", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } } } }, "default": { "description": "Unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorModel" } } } } } ``` ```yaml '200': description: a pet to be returned content: application/json: schema: $ref: '#/components/schemas/Pet' default: description: Unexpected error content: application/json: schema: $ref: '#/components/schemas/ErrorModel' ``` -------------------------------- ### Example: OpenAPI Response Object - Simple String Type Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Shows an OpenAPI Response Object definition for a simple string response, specifying the `text/plain` media type and a string schema. ```json { "description": "A simple string response", "content": { "text/plain": { "schema": { "type": "string" } } } } ``` ```yaml description: A simple string response content: text/plain: schema: type: string ``` -------------------------------- ### Example OpenAPI Contact Object (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Illustrates the structure of an OpenAPI Contact Object in YAML format. This object provides contact information for the API, including name, URL, and email address. ```yaml name: API Support url: https://www.example.com/support email: support@example.com ``` -------------------------------- ### Example OAuth2 Flow Object in YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This YAML example provides an alternative representation of the OAuth Flow Object, mirroring the JSON structure. It illustrates how to define 'implicit' and 'authorizationCode' flows with their respective authorization and token URLs and associated scopes. ```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 ``` -------------------------------- ### Example Payload Matching allOf with Parent Discriminator (Implicit) - JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides a JSON payload example that matches the `allOf` schema structure where the parent schema defines the discriminator. The `petType` value ("Cat") implicitly maps to the `Cat` schema, indicating it should be used for validation. ```json { "petType": "Cat", "name": "misty" } ``` -------------------------------- ### Defining API Responses in OpenAPI (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This YAML example shows the structure of the OpenAPI `responses` object. It includes a specific '200' response definition for a successful operation and a 'default' response definition for unexpected errors, mirroring the JSON example. ```yaml '200': description: a pet to be returned content: application/json: schema: $ref: '#/components/schemas/Pet' default: description: Unexpected error content: application/json: schema: $ref: '#/components/schemas/ErrorModel' ``` -------------------------------- ### Valid Field Name Examples in OAS Components Object Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This snippet provides examples of valid keys that can be used for the fixed fields within the OpenAPI Specification Components Object. These keys must match the regular expression `^[a-zA-Z0-9\.\-_]+$`. ```text User User_1 User_Name user-name my.org.User ``` -------------------------------- ### Configuring Basic Authentication (HTTP) - Multiple Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Example configuration for a basic HTTP authentication security scheme. It specifies the type as 'http' and the scheme as 'basic' according to RFC7235. ```json { "type": "http", "scheme": "basic" } ``` ```yaml type: http scheme: basic ``` -------------------------------- ### Defining String Response in OpenAPI (JSON/YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Example showing how to define an OpenAPI response object that returns a simple string type. ```json { "description": "A simple string response", "content": { "text/plain": { "schema": { "type": "string" } } } } ``` ```yaml description: A simple string response content: text/plain: schema: type: string ``` -------------------------------- ### Example Payload Matching allOf with Parent Discriminator (Explicit) - JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides a JSON payload example that matches the `allOf` schema structure where the parent schema defines the discriminator with explicit mapping. The `petType` value ("dog") explicitly maps to the `Dog` schema via the `mapping` definition, indicating it should be used for validation. ```json { "petType": "dog", "bark": "soft" } ``` -------------------------------- ### Example OpenAPI Contact Object (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Illustrates the structure of an OpenAPI Contact Object in JSON format. This object provides contact information for the API, including name, URL, and email address. ```json { "name": "API Support", "url": "https://www.example.com/support", "email": "support@example.com" } ``` -------------------------------- ### Defining Request Body with Referenced Schema - YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This snippet provides the YAML equivalent of defining a request body in OpenAPI that references a schema definition and includes examples for various media types. It illustrates the YAML syntax for structuring the 'content' object with different media type keys and nested example objects. ```yaml description: user to add to the system content: 'application/json': schema: $ref: '#/components/schemas/User' examples: user: summary: User Example externalValue: 'https://foo.bar/examples/user-example.json' 'application/xml': schema: $ref: '#/components/schemas/User' examples: user: summary: User example in XML externalValue: 'https://foo.bar/examples/user-example.xml' 'text/plain': examples: user: summary: User example in Plain text externalValue: 'https://foo.bar/examples/user-example.txt' '*/*': examples: user: summary: User example in other format externalValue: 'https://foo.bar/examples/user-example.whatever' ``` -------------------------------- ### Defining Response with Headers in OpenAPI (JSON/YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Example showing how to define an OpenAPI response object that includes headers along with a string content type. ```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" } } } } ``` ```yaml 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 ``` -------------------------------- ### Initializing Authenticated Client Python Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Shows how to create an authenticated client instance using the `AuthenticatedClient` class, providing both the base URL and an authentication token. ```python from my_test_api_client import AuthenticatedClient client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken") ``` -------------------------------- ### Example Optional OAuth2 Security Requirement in YAML Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This YAML example illustrates optional security using a list of Security Requirement Objects. The list includes an empty object (for no security) and an OAuth2 requirement, allowing the request to be authorized by either satisfying the OAuth2 scheme with scopes or requiring no security. ```yaml security: - {} - petstore_auth: - write:pets - read:pets ``` -------------------------------- ### Example Payload Matching oneOf with propertyName Discriminator - JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Provides an example JSON payload that conforms to a schema defined with `oneOf` and a `propertyName` discriminator. The value of the `petType` field ("Cat") indicates which schema (`Cat`) should be used to validate this payload. ```json { "id": 12345, "petType": "Cat" } ``` -------------------------------- ### External Documentation Object Example - JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This JSON object illustrates the structure of an OpenAPI External Documentation Object, used to reference external resources for extended documentation, including a description and a required URL. ```json { "description": "Find more info here", "url": "https://example.com" } ``` -------------------------------- ### Customizing Python Client with httpx Event Hooks Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/test-3-1-golden-record/README.md Demonstrates how to pass arguments directly to the underlying `httpx.Client` or `httpx.AsyncClient` via the `httpx_args` parameter. This example adds event hooks to log requests and responses. ```python from test_3_1_features_client import Client def log_request(request): print(f"Request event hook: {request.method} {request.url} - Waiting for response") def log_response(response): request = response.request print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}") client = Client( base_url="https://api.example.com", httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}, ) # Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client() ``` -------------------------------- ### Example JSON Array Field (JSON) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md This snippet demonstrates how an array value is represented in JSON format within an OpenAPI document, illustrating the standard JSON array syntax. ```json { "field": [ 1, 2, 3 ] } ``` -------------------------------- ### OAuth2 Implicit and Authorization Code Flows (OpenAPI) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Example demonstrating the structure for defining an OAuth2 security scheme object that includes configurations for both the implicit and authorization code flows. It shows the required URLs and scopes for each flow. ```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 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 ``` -------------------------------- ### Example Optional OAuth2 Security Requirement in JSON Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This JSON example shows how to define optional security using a list of Security Requirement Objects. The list contains an empty object (representing no security required) and an OAuth2 requirement, meaning either no security or the specified OAuth2 scheme with scopes will satisfy the requirement. ```json { "security": [ {}, { "petstore_auth": [ "write:pets", "read:pets" ] } ] } ``` -------------------------------- ### JSON Array Example Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Demonstrates the representation of an array value for a field within a JSON object, as used in the OpenAPI Specification format. ```json { "field": [ 1, 2, 3 ] } ``` -------------------------------- ### Defining OpenAPI Components Object (YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md This snippet presents the same OpenAPI `components` object structure as the JSON example, but in YAML format. It defines reusable schemas, parameters, responses, and security schemes that can be referenced elsewhere in the OpenAPI document to promote consistency and reduce redundancy. ```yaml components: schemas: GeneralError: type: object properties: code: type: integer format: int32 message: type: string Category: type: object properties: id: type: integer format: int64 name: type: string Tag: type: object properties: id: type: integer format: int64 name: type: string parameters: skipParam: name: skip in: query description: number of items to skip required: true schema: type: integer format: int32 limitParam: name: limit in: query description: max records to return required: true schema: type: integer format: int32 responses: NotFound: description: Entity not found. IllegalInput: description: Illegal input for operation. GeneralError: description: General Error content: application/json: schema: $ref: '#/components/schemas/GeneralError' securitySchemes: api_key: type: apiKey name: api_key in: header petstore_auth: type: oauth2 flows: implicit: authorizationUrl: https://example.org/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets ``` -------------------------------- ### Making Asynchronous API Call Python Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Demonstrates how to make a non-blocking asynchronous API call using the initialized client. It shows how to retrieve parsed data directly or get a detailed response object using `await`. ```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 async with client as client: my_data: MyDataModel = await get_my_data_model.asyncio(client=client) response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client) ``` -------------------------------- ### Defining No Content Response in OpenAPI (JSON/YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Example showing how to define an OpenAPI response object that indicates no content is returned, typically for operations like creation. ```json { "description": "object created" } ``` ```yaml description: object created ``` -------------------------------- ### Implicit OAuth2 Security Scheme (OpenAPI) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Example demonstrating the structure for defining an OAuth2 security scheme object using the implicit flow in OpenAPI. It includes the authorization URL and defined scopes. ```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 type: oauth2 flows: implicit: authorizationUrl: https://example.com/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets ``` -------------------------------- ### Configure Client with httpx Event Hooks Python Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/literal-enums-golden-record/README.md Customize the underlying httpx client by providing arguments via `httpx_args`. This example shows how to add request and response event hooks for logging. ```python from my_enum_api_client import Client def log_request(request): print(f"Request event hook: {request.method} {request.url} - Waiting for response") def log_response(response): request = response.request print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}") client = Client( base_url="https://api.example.com", httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}}, ) # Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client() ``` -------------------------------- ### Example: OpenAPI Response Object - Array of Complex Type Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.0.3.md Demonstrates an OpenAPI Response Object definition for a successful response containing an array of complex objects, referencing a schema defined elsewhere. ```json { "description": "A complex object array response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/VeryComplexType" } } } } } ``` ```yaml description: A complex object array response content: application/json: schema: type: array items: $ref: '#/components/schemas/VeryComplexType' ``` -------------------------------- ### Defining Array Response in OpenAPI (JSON/YAML) Source: https://github.com/benchling/openapi-python-client/blob/main/openapi_python_client/schema/3.1.0.md Example showing how to define an OpenAPI response object that returns an array of a complex type, referencing a schema definition. ```json { "description": "A complex object array response", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/VeryComplexType" } } } } } ``` ```yaml description: A complex object array response content: application/json: schema: type: array items: $ref: '#/components/schemas/VeryComplexType' ``` -------------------------------- ### Publish Package to Public PyPI Source: https://github.com/benchling/openapi-python-client/blob/main/end_to_end_tests/golden-record/README.md Builds and publishes the Python package to the default public PyPI repository. ```bash poetry publish --build ```