Merge pull request #664 from metosin/fix-swagger-tests

Fix: swagger tests and CI
This commit is contained in:
Martín Varela 2024-02-09 11:48:59 +02:00 committed by GitHub
commit 98f3eb0a72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 9 deletions

View file

@ -32,6 +32,9 @@ jobs:
uses: DeLaGuardo/setup-clojure@3.1
with:
lein: 2.9.5
- name: Install dependencies
run: |
npm ci
- name: Run tests
run: ./scripts/test.sh clj

View file

@ -652,12 +652,14 @@
:uri "/foo"
:muuntaja/request {:format request-format}
:muuntaja/response {:format response-format}
:body-params body})]
:body-params body})
normalize-json (fn[body]
(-> body j/write-value-as-string (j/read-value j/keyword-keys-object-mapper)))]
(testing "succesful call"
(is (= {:status 200 :body {:request :json, :response :json}}
(call (request "application/json" "application/json" {:request :json :response :json}))))
(is (= {:status 200 :body {:request :edn, :response :json}}
(call (request "application/edn" "application/json" {:request :edn :response :json}))))
(is (= {:status 200 :body {:request "json", :response "json"}}
(normalize-json (call (request "application/json" "application/json" {:request :json :response :json})))))
(is (= {:status 200 :body {:request "edn", :response "json"}}
(normalize-json (call (request "application/edn" "application/json" {:request :edn :response :json})))))
(is (= {:status 200 :body {:request :default, :response :default}}
(call (request "application/transit" "application/transit" {:request :default :response :default})))))
(testing "request validation fails"

View file

@ -161,14 +161,14 @@
expected {:x-id #{::math}
:swagger "2.0"
:info {:title "my-api"}
:definitions {::req-key {:type "string"
:definitions {"reitit.swagger-test/req-key" {:type "string"
:x-anyOf [{:type "string"}
{:type "string"}]}
::req-val {:type "object"
"reitit.swagger-test/req-val" {:type "object"
:x-anyOf [{:type "object"}
{:type "string"}]}
::resp-map {:type "object"},
::resp-string {:type "string"
"reitit.swagger-test/resp-map" {:type "object"},
"reitit.swagger-test/resp-string" {:type "string"
:minLength 1}}
:paths {"/api/spec/plus/{z}" {:patch {:parameters []
:summary "patch"