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

10 KiB

StoreApi

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

Method HTTP request Description
deleteOrder DELETE /store/order/{orderId} Delete purchase order by ID
deleteOrderWithHttpInfo DELETE /store/order/{orderId} Delete purchase order by ID
getInventory GET /store/inventory Returns pet inventories by status
getInventoryWithHttpInfo GET /store/inventory Returns pet inventories by status
getOrderById GET /store/order/{orderId} Find purchase order by ID
getOrderByIdWithHttpInfo GET /store/order/{orderId} Find purchase order by ID
placeOrder POST /store/order Place an order for a pet
placeOrderWithHttpInfo POST /store/order Place an order for a pet

deleteOrder

deleteOrder(deleteOrderRequest): ApiRequest[Unit]

Delete purchase order by ID

For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors

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 = StoreApi("https://petstore.swagger.io/v2")
    val orderId: String = orderId_example // String | ID of the order that needs to be deleted
    
    val request = apiInstance.deleteOrder(orderId)
    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 StoreApi#deleteOrder")
            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 StoreApi#deleteOrder")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
orderId String ID of the order that needs to be deleted

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 ID supplied -
404 Order not found -

getInventory

getInventory(): ApiRequest[Map[String, Int]]

Returns pet inventories by status

Returns a map of status codes to quantities

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
    
    // Configure API key authorization: api_key
    implicit val api_key: ApiKeyValue = ApiKeyValue("YOUR API KEY")

    val apiInvoker = ApiInvoker()
    val apiInstance = StoreApi("https://petstore.swagger.io/v2")    
    val request = apiInstance.getInventory()
    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 StoreApi#getInventory")
            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 StoreApi#getInventory")
            exception.printStackTrace();
    }
}

Parameters

This endpoint does not need any parameter.

Return type

ApiRequest[Map[String, Int]]

Authorization

api_key

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 successful operation -

getOrderById

getOrderById(getOrderByIdRequest): ApiRequest[Order]

Find purchase order by ID

For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions

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 = StoreApi("https://petstore.swagger.io/v2")
    val orderId: Long = 789 // Long | ID of pet that needs to be fetched
    
    val request = apiInstance.getOrderById(orderId)
    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 StoreApi#getOrderById")
            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 StoreApi#getOrderById")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
orderId Long ID of pet that needs to be fetched

Return type

ApiRequest[Order]

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 ID supplied -
404 Order not found -

placeOrder

placeOrder(placeOrderRequest): ApiRequest[Order]

Place an order for a 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 = StoreApi("https://petstore.swagger.io/v2")
    val order: Order =  // Order | order placed for purchasing the pet
    
    val request = apiInstance.placeOrder(order)
    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 StoreApi#placeOrder")
            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 StoreApi#placeOrder")
            exception.printStackTrace();
    }
}

Parameters

Name Type Description Notes
order Order order placed for purchasing the pet

Return type

ApiRequest[Order]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid Order -