Mickael Magniez 38c33b92fe
Add scala-pekko client generator (#17417)
* feat: add scala-pekko client generator

* feat: add scala-pekko client to CI
2023-12-22 10:58:27 +08:00

20 KiB

PetApi

All URIs are relative to https://petstore.swagger.io/v2

Method HTTP request Description
addPet POST /pet Add a new pet to the store
addPetWithHttpInfo POST /pet Add a new pet to the store
deletePet DELETE /pet/{petId} Deletes a pet
deletePetWithHttpInfo DELETE /pet/{petId} Deletes a pet
findPetsByStatus GET /pet/findByStatus Finds Pets by status
findPetsByStatusWithHttpInfo GET /pet/findByStatus Finds Pets by status
findPetsByTags GET /pet/findByTags Finds Pets by tags
findPetsByTagsWithHttpInfo GET /pet/findByTags Finds Pets by tags
getPetById GET /pet/{petId} Find pet by ID
getPetByIdWithHttpInfo GET /pet/{petId} Find pet by ID
updatePet PUT /pet Update an existing pet
updatePetWithHttpInfo PUT /pet Update an existing pet
updatePetWithForm POST /pet/{petId} Updates a pet in the store with form data
updatePetWithFormWithHttpInfo POST /pet/{petId} Updates a pet in the store with form data
uploadFile POST /pet/{petId}/uploadImage uploads an image
uploadFileWithHttpInfo POST /pet/{petId}/uploadImage uploads an image

addPet

addPet(addPetRequest): ApiRequest[Pet]

Add a new pet to the store

Example

// Import classes:
import 
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val pet: Pet =  // Pet | Pet object that needs to be added to the store
    
    val request = apiInstance.addPet(pet)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
            System.out.println(s"Response body: $content")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#addPet")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#addPet")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
pet Pet Pet object that needs to be added to the store

Return type

ApiRequest[Pet]

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
405 Invalid input -

deletePet

deletePet(deletePetRequest): ApiRequest[Unit]

Deletes a pet

Example

// Import classes:
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val petId: Long = 789 // Long | Pet id to delete

    val apiKey: String = apiKey_example // String | 
    
    val request = apiInstance.deletePet(petId, apiKey)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#deletePet")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#deletePet")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
petId Long Pet id to delete
apiKey String [optional]

Return type

ApiRequest[Unit] (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

HTTP response details

Status code Description Response headers
400 Invalid pet value -

findPetsByStatus

findPetsByStatus(findPetsByStatusRequest): ApiRequest[Seq[Pet]]

Finds Pets by status

Multiple status values can be provided with comma separated strings

Example

// Import classes:
import 
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val status: Seq[String] =  // Seq[String] | Status values that need to be considered for filter
    
    val request = apiInstance.findPetsByStatus(status)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
            System.out.println(s"Response body: $content")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#findPetsByStatus")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#findPetsByStatus")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
status Seq[String] Status values that need to be considered for filter [enum: available, pending, sold]

Return type

ApiRequest[Seq[Pet]]

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid status value -

findPetsByTags

findPetsByTags(findPetsByTagsRequest): ApiRequest[Seq[Pet]]

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Example

// Import classes:
import 
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val tags: Seq[String] =  // Seq[String] | Tags to filter by
    
    val request = apiInstance.findPetsByTags(tags)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
            System.out.println(s"Response body: $content")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#findPetsByTags")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#findPetsByTags")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
tags Seq[String] Tags to filter by

Return type

ApiRequest[Seq[Pet]]

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid tag value -

getPetById

getPetById(getPetByIdRequest): ApiRequest[Pet]

Find pet by ID

Returns a single pet

Example

// Import classes:
import 
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    // Configure API key authorization: api_key
    implicit val api_key: ApiKeyValue = ApiKeyValue("YOUR API KEY")

    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val petId: Long = 789 // Long | ID of pet to return
    
    val request = apiInstance.getPetById(petId)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
            System.out.println(s"Response body: $content")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#getPetById")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#getPetById")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
petId Long ID of pet to return

Return type

ApiRequest[Pet]

Authorization

api_key

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid ID supplied -
404 Pet not found -

updatePet

updatePet(updatePetRequest): ApiRequest[Pet]

Update an existing pet

Example

// Import classes:
import 
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val pet: Pet =  // Pet | Pet object that needs to be added to the store
    
    val request = apiInstance.updatePet(pet)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
            System.out.println(s"Response body: $content")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#updatePet")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#updatePet")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
pet Pet Pet object that needs to be added to the store

Return type

ApiRequest[Pet]

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid ID supplied -
404 Pet not found -
405 Validation exception -

updatePetWithForm

updatePetWithForm(updatePetWithFormRequest): ApiRequest[Unit]

Updates a pet in the store with form data

Example

// Import classes:
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val petId: Long = 789 // Long | ID of pet that needs to be updated

    val name: String = name_example // String | Updated name of the pet

    val status: String = status_example // String | Updated status of the pet
    
    val request = apiInstance.updatePetWithForm(petId, name, status)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#updatePetWithForm")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#updatePetWithForm")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
petId Long ID of pet that needs to be updated
name String Updated name of the pet [optional]
status String Updated status of the pet [optional]

Return type

ApiRequest[Unit] (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: Not defined

HTTP response details

Status code Description Response headers
200 successful operation -
405 Invalid input -

uploadFile

uploadFile(uploadFileRequest): ApiRequest[ApiResponse]

uploads an image

Example

// Import classes:
import 
import 
import org.openapitools.client.core._
import org.openapitools.client.core.CollectionFormats._
import org.openapitools.client.core.ApiKeyLocations._

import org.apache.pekko.actor.ActorSystem
import scala.concurrent.Future
import scala.util.{Failure, Success}

object Example extends App {
    
    implicit val system: ActorSystem = ActorSystem()
    import system.dispatcher
    
    val apiInvoker = ApiInvoker()
    val apiInstance = PetApi("https://petstore.swagger.io/v2")
    val petId: Long = 789 // Long | ID of pet to update

    val additionalMetadata: String = additionalMetadata_example // String | Additional data to pass to server

    val file: File = BINARY_DATA_HERE // File | file to upload
    
    val request = apiInstance.uploadFile(petId, additionalMetadata, file)
    val response = apiInvoker.execute(request)

    response.onComplete {
        case Success(ApiResponse(code, content, headers)) =>
            System.out.println(s"Status code: $code}")
            System.out.println(s"Response headers: ${headers.mkString(", ")}")
            System.out.println(s"Response body: $content")
        
        case Failure(error @ ApiError(code, message, responseContent, cause, headers)) =>
            System.err.println("Exception when calling PetApi#uploadFile")
            System.err.println(s"Status code: $code}")
            System.err.println(s"Reason: $responseContent")
            System.err.println(s"Response headers: ${headers.mkString(", ")}")
            error.printStackTrace();

        case Failure(exception) => 
            System.err.println("Exception when calling PetApi#uploadFile")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
petId Long ID of pet to update
additionalMetadata String Additional data to pass to server [optional]
file File file to upload [optional]

Return type

ApiRequest[ApiResponse]

Authorization

No authorization required

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 successful operation -