forked from loafle/openapi-generator-original
Clojure client: update Petstore sample, fix tests
This commit is contained in:
parent
3106cadaf7
commit
a42f972dfe
@ -48,7 +48,7 @@
|
||||
|
||||
(defn find-pets-by-status-with-http-info
|
||||
"Finds Pets by status
|
||||
Multiple status values can be provided with comma seperated strings"
|
||||
Multiple status values can be provided with comma separated strings"
|
||||
([] (find-pets-by-status-with-http-info nil))
|
||||
([{:keys [status ]}]
|
||||
(call-api "/pet/findByStatus" :get
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
(defn find-pets-by-status
|
||||
"Finds Pets by status
|
||||
Multiple status values can be provided with comma seperated strings"
|
||||
Multiple status values can be provided with comma separated strings"
|
||||
([] (find-pets-by-status nil))
|
||||
([optional-params]
|
||||
(:data (find-pets-by-status-with-http-info optional-params))))
|
||||
@ -99,7 +99,7 @@
|
||||
:form-params {}
|
||||
:content-types []
|
||||
:accepts ["application/json" "application/xml"]
|
||||
:auth-names ["api_key"]}))
|
||||
:auth-names ["petstore_auth" "api_key"]}))
|
||||
|
||||
(defn get-pet-by-id
|
||||
"Find pet by ID
|
||||
@ -169,3 +169,44 @@
|
||||
([pet-id ] (upload-file pet-id nil))
|
||||
([pet-id optional-params]
|
||||
(:data (upload-file-with-http-info pet-id optional-params))))
|
||||
|
||||
(defn pet-pet-idtesting-byte-arraytrue-get-with-http-info
|
||||
"Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions"
|
||||
[pet-id ]
|
||||
(call-api "/pet/{petId}?testing_byte_array=true" :get
|
||||
{:path-params {"petId" pet-id }
|
||||
:header-params {}
|
||||
:query-params {}
|
||||
:form-params {}
|
||||
:content-types []
|
||||
:accepts ["application/json" "application/xml"]
|
||||
:auth-names ["petstore_auth" "api_key"]}))
|
||||
|
||||
(defn pet-pet-idtesting-byte-arraytrue-get
|
||||
"Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions"
|
||||
[pet-id ]
|
||||
(:data (pet-pet-idtesting-byte-arraytrue-get-with-http-info pet-id)))
|
||||
|
||||
(defn add-pet-using-byte-array-with-http-info
|
||||
"Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
"
|
||||
([] (add-pet-using-byte-array-with-http-info nil))
|
||||
([{:keys [body ]}]
|
||||
(call-api "/pet?testing_byte_array=true" :post
|
||||
{:path-params {}
|
||||
:header-params {}
|
||||
:query-params {}
|
||||
:form-params {}
|
||||
:body-param body
|
||||
:content-types ["application/json" "application/xml"]
|
||||
:accepts ["application/json" "application/xml"]
|
||||
:auth-names ["petstore_auth"]})))
|
||||
|
||||
(defn add-pet-using-byte-array
|
||||
"Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
"
|
||||
([] (add-pet-using-byte-array nil))
|
||||
([optional-params]
|
||||
(:data (add-pet-using-byte-array-with-http-info optional-params))))
|
||||
|
@ -2,6 +2,27 @@
|
||||
(:require [swagger-petstore.core :refer [call-api check-required-params with-collection-format]])
|
||||
(:import (java.io File)))
|
||||
|
||||
(defn find-orders-by-status-with-http-info
|
||||
"Finds orders by status
|
||||
A single status value can be provided as a string"
|
||||
([] (find-orders-by-status-with-http-info nil))
|
||||
([{:keys [status ]}]
|
||||
(call-api "/store/findByStatus" :get
|
||||
{:path-params {}
|
||||
:header-params {}
|
||||
:query-params {"status" status }
|
||||
:form-params {}
|
||||
:content-types []
|
||||
:accepts ["application/json" "application/xml"]
|
||||
:auth-names ["test_api_client_id" "test_api_client_secret"]})))
|
||||
|
||||
(defn find-orders-by-status
|
||||
"Finds orders by status
|
||||
A single status value can be provided as a string"
|
||||
([] (find-orders-by-status nil))
|
||||
([optional-params]
|
||||
(:data (find-orders-by-status-with-http-info optional-params))))
|
||||
|
||||
(defn get-inventory-with-http-info
|
||||
"Returns pet inventories by status
|
||||
Returns a map of status codes to quantities"
|
||||
@ -34,7 +55,7 @@
|
||||
:body-param body
|
||||
:content-types []
|
||||
:accepts ["application/json" "application/xml"]
|
||||
:auth-names []})))
|
||||
:auth-names ["test_api_client_id" "test_api_client_secret"]})))
|
||||
|
||||
(defn place-order
|
||||
"Place an order for a pet
|
||||
@ -54,7 +75,7 @@
|
||||
:form-params {}
|
||||
:content-types []
|
||||
:accepts ["application/json" "application/xml"]
|
||||
:auth-names []}))
|
||||
:auth-names ["test_api_key_query" "test_api_key_header"]}))
|
||||
|
||||
(defn get-order-by-id
|
||||
"Find purchase order by ID
|
||||
|
@ -9,7 +9,11 @@
|
||||
|
||||
(def auth-definitions
|
||||
{"petstore_auth" {:type :oauth2}
|
||||
"api_key" {:type :api-key :in :header :param-name "api_key"}})
|
||||
"test_api_client_id" {:type :api-key :in :header :param-name "x-test_api_client_id"}
|
||||
"test_api_client_secret" {:type :api-key :in :header :param-name "x-test_api_client_secret"}
|
||||
"api_key" {:type :api-key :in :header :param-name "api_key"}
|
||||
"test_api_key_query" {:type :api-key :in :query :param-name "test_api_key_query"}
|
||||
"test_api_key_header" {:type :api-key :in :header :param-name "test_api_key_header"}})
|
||||
|
||||
(def default-api-context
|
||||
"Default API context."
|
||||
@ -18,7 +22,11 @@
|
||||
:datetime-format "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
|
||||
:debug false
|
||||
:auths {"petstore_auth" nil
|
||||
"api_key" nil}})
|
||||
"test_api_client_id" nil
|
||||
"test_api_client_secret" nil
|
||||
"api_key" nil
|
||||
"test_api_key_query" nil
|
||||
"test_api_key_header" nil}})
|
||||
|
||||
(def ^:dynamic *api-context*
|
||||
"Dynamic API context to be applied in API calls."
|
||||
|
@ -11,7 +11,11 @@
|
||||
:datetime-format "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
|
||||
:debug false
|
||||
:auths {"api_key" nil
|
||||
"petstore_auth" nil}}
|
||||
"petstore_auth" nil
|
||||
"test_api_client_id" nil
|
||||
"test_api_client_secret" nil
|
||||
"test_api_key_query" nil
|
||||
"test_api_key_header" nil}}
|
||||
default-api-context
|
||||
*api-context*
|
||||
(with-api-context {}
|
||||
@ -25,8 +29,9 @@
|
||||
:date-format "yyyy-MM-dd"
|
||||
:datetime-format "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
|
||||
:debug true
|
||||
:auths {"api_key" "key1"
|
||||
"petstore_auth" "token1"}}
|
||||
:auths (merge (:auths default-api-context)
|
||||
{"api_key" "key1"
|
||||
"petstore_auth" "token1"})}
|
||||
*api-context*))
|
||||
;; nested with-api-context inherits values from the outer api context
|
||||
(with-api-context {:datetime-format "yyyy-MM-dd HH:mm:ss"
|
||||
@ -35,8 +40,9 @@
|
||||
:date-format "yyyy-MM-dd"
|
||||
:datetime-format "yyyy-MM-dd HH:mm:ss"
|
||||
:debug true
|
||||
:auths {"api_key" "key2"
|
||||
"petstore_auth" "token1"}}
|
||||
:auths (merge (:auths default-api-context)
|
||||
{"api_key" "key2"
|
||||
"petstore_auth" "token1"})}
|
||||
*api-context*))))
|
||||
;; back to default api context
|
||||
(is (= {:base-url "http://petstore.swagger.io/v2"
|
||||
@ -44,7 +50,11 @@
|
||||
:datetime-format "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
|
||||
:debug false
|
||||
:auths {"api_key" nil
|
||||
"petstore_auth" nil}}
|
||||
"petstore_auth" nil
|
||||
"test_api_client_id" nil
|
||||
"test_api_client_secret" nil
|
||||
"test_api_key_query" nil
|
||||
"test_api_key_header" nil}}
|
||||
default-api-context
|
||||
*api-context*))))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user