### Install Composer Dependencies for Slim Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/slim/vendor/slim/slim/example/README.md Installs project dependencies using Composer. This step ensures all required PHP libraries for the Slim framework are downloaded and configured. ```shell $ cd Slim $ composer install ``` -------------------------------- ### Run Slim PHP Development Server Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/slim/vendor/slim/slim/example/README.md Starts a local PHP development server to host the Slim application. It listens on localhost:8888 and serves files from the 'example' directory. ```shell $ cd Slim $ php -S localhost:8888 -t example example/index.php ``` -------------------------------- ### Install Composer Dependencies for Slim Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore-security-test/slim/vendor/slim/slim/example/README.md Installs project dependencies using Composer. This step ensures all required PHP libraries for the Slim framework are downloaded and configured. ```shell $ cd Slim $ composer install ``` -------------------------------- ### Run Slim PHP Development Server Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore-security-test/slim/vendor/slim/slim/example/README.md Starts a local PHP development server to host the Slim application. It listens on localhost:8888 and serves files from the 'example' directory. ```shell $ cd Slim $ php -S localhost:8888 -t example example/index.php ``` -------------------------------- ### Java Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/okhttp4-gson/README.md Example Java code demonstrating how to instantiate and use the AnotherFakeApi client, including exception handling. ```java import io.swagger.client.*; import io.swagger.client.auth.*; import io.swagger.client.model.*; import io.swagger.client.api.AnotherFakeApi; import java.io.File; import java.util.*; public class AnotherFakeApiExample { public static void main(String[] args) { AnotherFakeApi apiInstance = new AnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.testSpecialTags(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnotherFakeApi#testSpecialTags"); e.printStackTrace(); } } } ``` -------------------------------- ### Getting Started Example (Perl) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore-security-test/perl/deep_module_test/README.md A complete Perl script demonstrating how to set up the library path, load API and model packages, instantiate an API client, and make a sample API call. Includes error handling for API exceptions. ```perl #!/usr/bin/perl use lib 'lib'; use strict; use warnings; # load the API package use Something::Deep::FakeApi; # load the models use Something::Deep::Object::ModelReturn; # for displaying the API response data use Data::Dumper; use Something::Deep::; my $api_instance = Something::Deep::->new( ); my $test_code_inject_*/_'_"_=end____\r\n_\n_\r = 'test_code_inject_*/_'_"_=end____\r\n_\n_\r_example'; # string | To test code injection */ ' " =_end -- \r\n \n \r eval { $api_instance->test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r); }; if ($@) { warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n"; } ``` -------------------------------- ### Getting Started Example (C#) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNet40/README.md Demonstrates how to initialize and use the Swagger Petstore API client in C#. It shows creating an API instance, preparing a request body, making a call to `TestSpecialTags`, and handling potential exceptions. ```C# using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class Example { public void main() { var apiInstance = new AnotherFakeApi(); var body = new ModelClient(); // ModelClient | client model try { // To test special tags ModelClient result = apiInstance.TestSpecialTags(body); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling AnotherFakeApi.TestSpecialTags: " + e.Message ); } } } } ``` -------------------------------- ### Java Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/okhttp4-gson-parcelableModel/README.md Example Java code demonstrating how to instantiate and use the AnotherFakeApi client, including exception handling. ```java import io.swagger.client.*; import io.swagger.client.auth.*; import io.swagger.client.model.*; import io.swagger.client.api.AnotherFakeApi; import java.io.File; import java.util.*; public class AnotherFakeApiExample { public static void main(String[] args) { AnotherFakeApi apiInstance = new AnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.testSpecialTags(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnotherFakeApi#testSpecialTags"); e.printStackTrace(); } } } ``` -------------------------------- ### Getting Started Example (C#) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md Demonstrates how to initialize and use the Swagger Petstore API client in C#. It shows creating an API instance, preparing a request body, making a call to `TestSpecialTags`, and handling potential exceptions. ```C# using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class Example { public void main() { var apiInstance = new AnotherFakeApi(); var body = new ModelClient(); // ModelClient | client model try { // To test special tags ModelClient result = apiInstance.TestSpecialTags(body); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling AnotherFakeApi.TestSpecialTags: " + e.Message ); } } } } ``` -------------------------------- ### Getting Started Example (C#) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNet35/README.md Demonstrates how to initialize and use the Swagger Petstore API client in C#. It shows creating an API instance, preparing a request body, making a call to `TestSpecialTags`, and handling potential exceptions. ```C# using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class Example { public void main() { var apiInstance = new AnotherFakeApi(); var body = new ModelClient(); // ModelClient | client model try { // To test special tags ModelClient result = apiInstance.TestSpecialTags(body); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling AnotherFakeApi.TestSpecialTags: " + e.Message ); } } } } ``` -------------------------------- ### C# Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/README.md Demonstrates how to configure authentication and make a basic API call to add a pet using the generated C# SDK. It includes error handling for API exceptions. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class Example { public void main() { // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; var apiInstance = new PetApi(); var body = new Pet(); // Pet | Pet object that needs to be added to the store try { // Add a new pet to the store apiInstance.AddPet(body); } catch (Exception e) { Debug.Print("Exception when calling PetApi.AddPet: " + e.Message ); } } } } ``` -------------------------------- ### Getting Started Example (C#) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClient/README.md Demonstrates how to initialize and use the Swagger Petstore API client in C#. It shows creating an API instance, preparing a request body, making a call to `TestSpecialTags`, and handling potential exceptions. ```C# using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class Example { public void main() { var apiInstance = new AnotherFakeApi(); var body = new ModelClient(); // ModelClient | client model try { // To test special tags ModelClient result = apiInstance.TestSpecialTags(body); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling AnotherFakeApi.TestSpecialTags: " + e.Message ); } } } } ``` -------------------------------- ### Install Python Client via Setuptools Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python-asyncio/README.md Installs the Petstore API Python client using Python's setuptools. This involves running the setup script. The package can be installed for the current user or system-wide. ```sh python setup.py install --user # Or for system-wide installation: sudo python setup.py install ``` -------------------------------- ### Install Python Client via Setuptools Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python-tornado/README.md Installs the Petstore API Python client using Python's setuptools. This involves running the setup script. The package can be installed for the current user or system-wide. ```sh python setup.py install --user # Or for system-wide installation: sudo python setup.py install ``` -------------------------------- ### Install Python Client via Setuptools Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python/README.md Installs the Petstore API Python client using Python's setuptools. This involves running the setup script. The package can be installed for the current user or system-wide. ```sh python setup.py install --user # Or for system-wide installation: sudo python setup.py install ``` -------------------------------- ### Rails Application Setup and Start Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/rails5/README.md Commands to create and migrate the database, and then start the Rails development server. These are essential steps for running the application locally. ```shell bin/rake db:create db:migrate bin/rails s ``` -------------------------------- ### Java Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/okhttp-gson-parcelableModel/README.md Demonstrates how to instantiate and use the AnotherFakeApi client. This example shows how to call the testSpecialTags method. ```java import io.swagger.client.*; import io.swagger.client.auth.*; import io.swagger.client.model.*; import io.swagger.client.api.AnotherFakeApi; import java.io.File; import java.util.*; public class AnotherFakeApiExample { public static void main(String[] args) { AnotherFakeApi apiInstance = new AnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.testSpecialTags(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnotherFakeApi#testSpecialTags"); e.printStackTrace(); } } } ``` -------------------------------- ### Java Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/okhttp-gson/README.md Demonstrates how to instantiate and use the AnotherFakeApi client. This example shows how to call the testSpecialTags method. ```java import io.swagger.client.*; import io.swagger.client.auth.*; import io.swagger.client.model.*; import io.swagger.client.api.AnotherFakeApi; import java.io.File; import java.util.*; public class AnotherFakeApiExample { public static void main(String[] args) { AnotherFakeApi apiInstance = new AnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.testSpecialTags(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnotherFakeApi#testSpecialTags"); e.printStackTrace(); } } } ``` -------------------------------- ### Getting Started Example: FakeApi Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore-security-test/php/SwaggerClient-php/README.md A basic PHP example demonstrating how to instantiate the FakeApi client and call the `testCodeInjectEndRnNR` method. It shows how to handle potential exceptions during API calls. ```php testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); } catch (Exception $e) { echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Create a Basic Slim Framework Application Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore-security-test/slim/vendor/slim/slim/README.md This example demonstrates how to create a minimal Slim Framework application. It sets up a new Slim application instance, defines a GET route for '/hello/{name}', and returns a personalized greeting. The application is then run. ```php get('/hello/{name}', function ($request, $response, $args) { $response->write("Hello, " . $args['name']); return $response; }); $app->run(); ``` -------------------------------- ### Create a Basic Slim Framework Application Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/slim/vendor/slim/slim/README.md This example demonstrates how to create a minimal Slim Framework application. It sets up a new Slim application instance, defines a GET route for '/hello/{name}', and returns a personalized greeting. The application is then run. ```php get('/hello/{name}', function ($request, $response, $args) { $response->write("Hello, " . $args['name']); return $response; }); $app->run(); ``` -------------------------------- ### Get Pet by ID Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/javascript-promise-es6/docs/PetApi.md Shows how to retrieve a specific pet using its unique ID. This example includes API key authentication setup and the call to `getPetById`. ```javascript import {SwaggerPetstore} from 'swagger_petstore'; let defaultClient = SwaggerPetstore.ApiClient.instance; // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix = 'Token'; let apiInstance = new SwaggerPetstore.PetApi(); let petId = 789; // Number | ID of pet to return apiInstance.getPetById(petId).then((data) => { console.log('API called successfully. Returned data: ' + data); }, (error) => { console.error(error); }); ``` -------------------------------- ### Java Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/google-api-client/README.md A basic Java example demonstrating how to instantiate and use the AnotherFakeApi client. It shows how to make a call to the testSpecialTags method and handle potential API exceptions. ```java import io.swagger.client.*; import io.swagger.client.auth.*; import io.swagger.client.model.*; import io.swagger.client.api.AnotherFakeApi; import java.io.File; import java.util.*; public class AnotherFakeApiExample { public static void main(String[] args) { AnotherFakeApi apiInstance = new AnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.testSpecialTags(body); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling AnotherFakeApi#testSpecialTags"); e.printStackTrace(); } } } ``` -------------------------------- ### Get Pet by ID Example (Python) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python-tornado/docs/PetApi.md Python code example for fetching a pet by its ID using the Petstore API. Demonstrates API key configuration, client setup, and calling the `get_pet_by_id` method. ```python from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException from pprint import pprint # Configure API key authorization: api_key configuration = petstore_api.Configuration() configuration.api_key['api_key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api_key'] = 'Bearer' # create an instance of the API class api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) pet_id = 789 # int | ID of pet to return try: # Find pet by ID api_response = api_instance.get_pet_by_id(pet_id) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->get_pet_by_id: %s\n" % e) ``` -------------------------------- ### Get Pet by ID Example (Python) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python-asyncio/docs/PetApi.md Python code example for fetching a pet by its ID using the Petstore API. Demonstrates API key configuration, client setup, and calling the `get_pet_by_id` method. ```python from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException from pprint import pprint # Configure API key authorization: api_key configuration = petstore_api.Configuration() configuration.api_key['api_key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api_key'] = 'Bearer' # create an instance of the API class api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) pet_id = 789 # int | ID of pet to return try: # Find pet by ID api_response = api_instance.get_pet_by_id(pet_id) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->get_pet_by_id: %s\n" % e) ``` -------------------------------- ### Get Pet by ID Example (Python) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python/docs/PetApi.md Python code example for fetching a pet by its ID using the Petstore API. Demonstrates API key configuration, client setup, and calling the `get_pet_by_id` method. ```python from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException from pprint import pprint # Configure API key authorization: api_key configuration = petstore_api.Configuration() configuration.api_key['api_key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['api_key'] = 'Bearer' # create an instance of the API class api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) pet_id = 789 # int | ID of pet to return try: # Find pet by ID api_response = api_instance.get_pet_by_id(pet_id) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->get_pet_by_id: %s\n" % e) ``` -------------------------------- ### Getting Started with Petstore API Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore-security-test/ruby/README.md Example Ruby code to initialize the Petstore API client and make a call to the `test_code_inject____end__rn_n_r` endpoint, including error handling. ```ruby # Load the gem require 'petstore' api_instance = Petstore::FakeApi.new opts = { test_code_inject____end____rn_n_r: "test_code_inject____end____rn_n_r_example" # String | To test code injection */ ' " =_end -- \r\n \n \r } begin #To test code injection */ ' " =_end -- \r\n \n \r api_instance.test_code_inject____end__rn_n_r(opts) rescue Petstore::ApiError => e puts "Exception when calling FakeApi->test_code_inject____end__rn_n_r: #{e}" end ``` -------------------------------- ### Perl SDK Getting Started Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/perl/README.md A complete example demonstrating how to set up the Perl SDK, load API packages and models, instantiate a client, and make a sample API call. It includes error handling for the API request. ```perl #!/usr/bin/perl use lib 'lib'; use strict; use warnings; # load the API package use WWW::SwaggerClient::AnotherFakeApi; use WWW::SwaggerClient::FakeApi; use WWW::SwaggerClient::FakeClassnameTags123Api; use WWW::SwaggerClient::PetApi; use WWW::SwaggerClient::StoreApi; use WWW::SwaggerClient::UserApi; # load the models use WWW::SwaggerClient::Object::AdditionalPropertiesClass; use WWW::SwaggerClient::Object::Animal; use WWW::SwaggerClient::Object::AnimalFarm; use WWW::SwaggerClient::Object::ApiResponse; use WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly; use WWW::SwaggerClient::Object::ArrayOfNumberOnly; use WWW::SwaggerClient::Object::ArrayTest; use WWW::SwaggerClient::Object::Capitalization; use WWW::SwaggerClient::Object::Category; use WWW::SwaggerClient::Object::ClassModel; use WWW::SwaggerClient::Object::Client; use WWW::SwaggerClient::Object::EnumArrays; use WWW::SwaggerClient::Object::EnumClass; use WWW::SwaggerClient::Object::EnumTest; use WWW::SwaggerClient::Object::FormatTest; use WWW::SwaggerClient::Object::HasOnlyReadOnly; use WWW::SwaggerClient::Object::List; use WWW::SwaggerClient::Object::MapTest; use WWW::SwaggerClient::Object::MixedPropertiesAndAdditionalPropertiesClass; use WWW::SwaggerClient::Object::Model200Response; use WWW::SwaggerClient::Object::ModelReturn; use WWW::SwaggerClient::Object::Name; use WWW::SwaggerClient::Object::NumberOnly; use WWW::SwaggerClient::Object::Order; use WWW::SwaggerClient::Object::OuterBoolean; use WWW::SwaggerClient::Object::OuterComposite; use WWW::SwaggerClient::Object::OuterEnum; use WWW::SwaggerClient::Object::OuterNumber; use WWW::SwaggerClient::Object::OuterString; use WWW::SwaggerClient::Object::Pet; use WWW::SwaggerClient::Object::ReadOnlyFirst; use WWW::SwaggerClient::Object::SpecialModelName; use WWW::SwaggerClient::Object::Tag; use WWW::SwaggerClient::Object::User; use WWW::SwaggerClient::Object::Cat; use WWW::SwaggerClient::Object::Dog; # for displaying the API response data use Data::Dumper; use WWW::SwaggerClient::; my $api_instance = WWW::SwaggerClient::->new( ); my $body = WWW::SwaggerClient::Object::Client->new(); # Client | client model eval { my $result = $api_instance->test_special_tags(body => $body); print Dumper($result); }; if ($@) { warn "Exception when calling AnotherFakeApi->test_special_tags: $@\n"; } ``` -------------------------------- ### Start Server with Maven Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/undertow/README.md Instructions to package and execute the Undertow server using Maven. This command compiles the project and runs the main server class. ```shell mvn package exec:exec ``` -------------------------------- ### Create User Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/UserApi.md C# example demonstrating how to create a new user using the UserApi. It shows instantiation of the API client, creation of a User object, and calling the CreateUser method. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class CreateUserExample { public void main() { var apiInstance = new UserApi(); var body = new User(); // User | Created user object try { // Create user apiInstance.CreateUser(body); } catch (Exception e) { Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); } } } } ``` -------------------------------- ### Getting Started with SwaggerClient-php Pet API Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/php/SwaggerClient-php/README.md A basic example demonstrating how to initialize the PetApi client and add a new pet using the library. It includes configuration for OAuth2 and error handling. ```php setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new Swagger\Client\Api\PetApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store try { $apiInstance->addPet($body); } catch (Exception $e) { echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Go Installation for Petstore API Client Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/go/go-petstore/README.md Instructions on how to install the generated Go API client. It requires placing the package under your project folder and adding the correct import statement. ```Go import "./petstore" ``` -------------------------------- ### JavaScript: Get Pet by ID Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/javascript-override-default-config/docs/PetApi.md Provides an example of retrieving a single pet by its unique ID using the Swagger Petstore JavaScript client. It includes API key authorization setup. ```javascript var SwaggerPetstore = require('swagger_petstore'); var defaultClient = SwaggerPetstore.ApiClient.instance; // Configure API key authorization: api_key var api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix = 'Token'; var apiInstance = new SwaggerPetstore.PetApi(); var petId = 789; // Number | ID of pet to return var callback = function(error, data, response) { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }; apiInstance.getPetById(petId, callback); ``` -------------------------------- ### JavaScript: Get Pet by ID Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/javascript/docs/PetApi.md Provides an example of retrieving a single pet by its unique ID using the Swagger Petstore JavaScript client. It includes API key authorization setup. ```javascript var SwaggerPetstore = require('swagger_petstore'); var defaultClient = SwaggerPetstore.ApiClient.instance; // Configure API key authorization: api_key var api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix = 'Token'; var apiInstance = new SwaggerPetstore.PetApi(); var petId = 789; // Number | ID of pet to return var callback = function(error, data, response) { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }; apiInstance.getPetById(petId, callback); ``` -------------------------------- ### Create User Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNetCoreProject/docs/UserApi.md C# example demonstrating how to create a new user using the UserApi. It shows instantiation of the API client, creation of a User object, and calling the CreateUser method. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class CreateUserExample { public void main() { var apiInstance = new UserApi(); var body = new User(); // User | Created user object try { // Create user apiInstance.CreateUser(body); } catch (Exception e) { Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); } } } } ``` -------------------------------- ### Verify Environment Setup Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/apex/README.md Commands to verify that Java and Ant are correctly installed and configured in the system's PATH and environment variables. ```bash java -version ant -version ``` -------------------------------- ### Go Installation for Petstore API Client Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/go/go-petstore-withXml/README.md Instructions on how to install the generated Go API client. It requires placing the package under your project folder and adding the correct import statement. ```Go import "./petstore" ``` -------------------------------- ### Create User Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md C# example demonstrating how to create a new user using the UserApi. It shows instantiation of the API client, creation of a User object, and calling the CreateUser method. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class CreateUserExample { public void main() { var apiInstance = new UserApi(); var body = new User(); // User | Created user object try { // Create user apiInstance.CreateUser(body); } catch (Exception e) { Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); } } } } ``` -------------------------------- ### Create User Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNet40/docs/UserApi.md C# example demonstrating how to create a new user using the UserApi. It shows instantiation of the API client, creation of a User object, and calling the CreateUser method. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class CreateUserExample { public void main() { var apiInstance = new UserApi(); var body = new User(); // User | Created user object try { // Create user apiInstance.CreateUser(body); } catch (Exception e) { Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); } } } } ``` -------------------------------- ### Create User Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/UserApi.md C# example demonstrating how to create a new user using the UserApi. It shows instantiation of the API client, creation of a User object, and calling the CreateUser method. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class CreateUserExample { public void main() { var apiInstance = new UserApi(); var body = new User(); // User | Created user object try { // Create user apiInstance.CreateUser(body); } catch (Exception e) { Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); } } } } ``` -------------------------------- ### Get User By Name Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md C# example demonstrating how to call the GetUserByName API endpoint. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class GetUserByNameExample { public void main() { var apiInstance = new UserApi(); var username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing. try { // Get user by user name User result = apiInstance.GetUserByName(username); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message ); } } } } ``` -------------------------------- ### Install Slim Framework using Composer Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore-security-test/slim/vendor/slim/slim/README.md This snippet shows the recommended way to install the Slim Framework using Composer, the dependency manager for PHP. It ensures all necessary dependencies are downloaded and configured correctly. Requires PHP 5.5.0 or newer. ```bash $ composer require slim/slim "^3.0" ``` -------------------------------- ### Configuration Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/haskell-http-client/example-app/infoLog.txt Example configuration settings for the Swagger client, including host and user agent. ```Haskell { configHost = "http://0.0.0.0/v2", configUserAgent = "swagger-haskell-http-client/1.0.0", ..} ``` -------------------------------- ### API Key Authorization Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore-security-test/go/README.md Example demonstrating how to use API key authentication for API requests. It shows setting the API key and prefix in the context. ```Go auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ Key: "APIKEY", Prefix: "Bearer", // Omit if not necessary. }) r, err := client.Service.Operation(auth, args) ``` -------------------------------- ### Get Inventory Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md C# example for retrieving pet inventories by status. Demonstrates API key configuration and handling the dictionary response. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class GetInventoryExample { public void main() { // Configure API key authorization: api_key Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); try { // Returns pet inventories by status Dictionary result = apiInstance.GetInventory(); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); } } } } ``` -------------------------------- ### Pimple 2 Installation Commands Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/server/petstore/slim/vendor/pimple/pimple/ext/pimple/README.md Provides the sequence of shell commands required to build and install the Pimple 2 C implementation. This process typically involves PHP's `phpize` tool, configuring the build, and then compiling and installing. ```Shell > phpize > ./configure > make > make install ``` -------------------------------- ### Get Inventory Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md C# example for retrieving pet inventories by status. Demonstrates API key configuration and handling the dictionary response. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class GetInventoryExample { public void main() { // Configure API key authorization: api_key Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); try { // Returns pet inventories by status Dictionary result = apiInstance.GetInventory(); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); } } } } ``` -------------------------------- ### Create User Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNet35/docs/UserApi.md C# example demonstrating how to create a new user using the UserApi. It shows instantiation of the API client, creation of a User object, and calling the CreateUser method. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class CreateUserExample { public void main() { var apiInstance = new UserApi(); var body = new User(); // User | Created user object try { // Create user apiInstance.CreateUser(body); } catch (Exception e) { Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); } } } } ``` -------------------------------- ### Get Inventory Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNetCoreProject/docs/StoreApi.md C# example for retrieving pet inventories by status. Demonstrates API key configuration and handling the dictionary response. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class GetInventoryExample { public void main() { // Configure API key authorization: api_key Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); try { // Returns pet inventories by status Dictionary result = apiInstance.GetInventory(); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); } } } } ``` -------------------------------- ### Manual Installation for SwaggerClient-php Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/php/SwaggerClient-php/README.md Steps for manually installing the SwaggerClient-php library by downloading files and including the autoloader. ```php require_once('/path/to/SwaggerClient-php/vendor/autoload.php'); ``` -------------------------------- ### Get Inventory Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNet40/docs/StoreApi.md C# example for retrieving pet inventories by status. Demonstrates API key configuration and handling the dictionary response. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class GetInventoryExample { public void main() { // Configure API key authorization: api_key Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); try { // Returns pet inventories by status Dictionary result = apiInstance.GetInventory(); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); } } } } ``` -------------------------------- ### Go API Client Installation Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore-security-test/go/README.md Instructions for installing the Go API client by placing the package under the project folder and adding it to imports. ```Go import "./swagger" ``` -------------------------------- ### Get Inventory Example Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClientNet35/docs/StoreApi.md C# example for retrieving pet inventories by status. Demonstrates API key configuration and handling the dictionary response. ```csharp using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; namespace Example { public class GetInventoryExample { public void main() { // Configure API key authorization: api_key Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); try { // Returns pet inventories by status Dictionary result = apiInstance.GetInventory(); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); } } } } ``` -------------------------------- ### Add Pet Example (Java) Source: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/google-api-client/docs/PetApi.md Example of how to add a new pet to the store using the Pet API client. It demonstrates setting up the API client, configuring authentication, creating a Pet object, and making the API call. ```Java ApiClient defaultClient = Configuration.getDefaultApiClient(); // Configure OAuth2 access token for authorization: petstore_auth OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(); Pet body = new Pet(); // Pet | Pet object that needs to be added to the store try { apiInstance.addPet(body); } catch (ApiException e) { System.err.println("Exception when calling PetApi#addPet"); e.printStackTrace(); } ```