From 10a19766e1395e6cf0bbb916fa9ef0370148f42c Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Wed, 1 May 2024 14:02:32 -0500 Subject: [PATCH] fmt --- src/ring/openapi/openapi3_schema.clj | 135 +++++++++++---------------- 1 file changed, 55 insertions(+), 80 deletions(-) diff --git a/src/ring/openapi/openapi3_schema.clj b/src/ring/openapi/openapi3_schema.clj index 8db5c15..c098220 100644 --- a/src/ring/openapi/openapi3_schema.clj +++ b/src/ring/openapi/openapi3_schema.clj @@ -1,40 +1,32 @@ (ns ring.openapi.openapi3-schema (:require [schema.core :as s] - [ring.swagger.swagger2-full-schema :refer [X- length-greater matches opt Contact Info]])) + [ring.swagger.swagger2-full-schema :refer [opt Info]])) (s/defschema Server-Variable - { - (opt :enum) [s/Str] - :default s/Str - (opt :description) s/Str - }) + {(opt :enum) [s/Str] + :default s/Str + (opt :description) s/Str}) (s/defschema Server - { - :url s/Str + {:url s/Str (opt :description) s/Str - (opt :variables) {s/Str Server-Variable} - }) + (opt :variables) {s/Str Server-Variable}}) (s/defschema ExternalDocumentation - { - (opt :description) s/Str - :url s/Str - }) + {(opt :description) s/Str + :url s/Str}) (s/defschema OpenApiSchemaPart {s/Keyword s/Any}) (s/defschema Example - { - (opt :summary) s/Str + {(opt :summary) s/Str (opt :description) s/Str (opt :value) s/Any (opt :externalValue) s/Str}) (s/defschema Header - { - (opt :description) s/Str + {(opt :description) s/Str :required s/Bool (opt :deprecated) s/Bool (opt :allowEmptyValue) s/Bool @@ -45,24 +37,20 @@ (opt :examples) {s/Str Example}}) (s/defschema Encoding - { - (opt :contentType) s/Str + {(opt :contentType) s/Str (opt :headers) {s/Str Header} (opt :style) s/Any (opt :explode) s/Bool (opt :allowReserved) s/Bool}) (s/defschema MediaObject - { - (opt :schema) OpenApiSchemaPart + {(opt :schema) OpenApiSchemaPart (opt :example) Example (opt :examples) {s/Str Example} - (opt :encoding) {s/Str Encoding} - }) + (opt :encoding) {s/Str Encoding}}) (s/defschema Parameter - { - :name s/Str + {:name s/Str (opt :in) s/Any (opt :description) s/Str :required s/Bool @@ -77,35 +65,33 @@ (opt :content) {s/Str MediaObject}}) (s/defschema RequestBody - { - (opt :description) s/Str + {(opt :description) s/Str :content {s/Str MediaObject} - (opt :required) s/Bool - }) + (opt :required) s/Bool}) (s/defschema Link - { - (opt :operationRef) s/Str + {(opt :operationRef) s/Str (opt :operationId) s/Str (opt :parameters) {s/Str s/Any} (opt :requestBody) s/Any (opt :description) s/Str - (opt :server) Server - }) + (opt :server) Server}) -(s/defschema ResponseCode (s/enum "100" "101" "102" "103" "200" "201" "202" "203" "204" "205" "206" "207" "208" "226" "300" "301" "302" "303" "304" "305" "306" "307" "308" "400" "401" "402" "403" "404" "405" "406" "407" "408" "409" "410" "411" "412" "413" "414" "415" "416" "417" "418" "419" "420" "421" "422" "423" "424" "425" "426" "428" "429" "431" "451" "500" "510" "502" "503" "504" "505" "506" "507" "508" "510" "511")) +(s/defschema ResponseCode + (s/enum "100" "101" "102" "103" "200" "201" "202" "203" "204" "205" "206" "207" "208" "226" + "300" "301" "302" "303" "304" "305" "306" "307" "308" + "400" "401" "402" "403" "404" "405" "406" "407" "408" "409" "410" "411" "412" "413" "414" "415" + "416" "417" "418" "419" "420" "421" "422" "423" "424" "425" "426" "428" "429" "431" "451" + "500" "510" "502" "503" "504" "505" "506" "507" "508" "510" "511")) (s/defschema Response - { - :description s/Str + {:description s/Str (opt :headers) {s/Str Header} (opt :content) {s/Str MediaObject} - (opt :links) {s/Str Link} - }) + (opt :links) {s/Str Link}}) (s/defschema Operation - { - (opt :tags) [s/Str] + {(opt :tags) [s/Str] (opt :summary) s/Str (opt :description) s/Str (opt :externalDocs) ExternalDocumentation @@ -115,55 +101,47 @@ (opt :responses) {ResponseCode Response} (opt :deprecated) s/Bool (opt :security) {s/Str [s/Str]} - (opt :servers) [Server] - }) + (opt :servers) [Server]}) (s/defschema Path - { - (opt :summary) s/Str + {(opt :summary) s/Str (opt :description) s/Str - (opt :get) Operation - (opt :put) Operation - (opt :post) Operation - (opt :delete) Operation - (opt :head) Operation - (opt :patch) Operation + (opt :get) Operation + (opt :put) Operation + (opt :post) Operation + (opt :delete) Operation + (opt :head) Operation + (opt :patch) Operation (opt :servers) [Server] - (opt :parameters) s/Any - }) + (opt :parameters) s/Any}) (s/defschema Callback {s/Str Path}) (s/defschema Tag - { - :name s/Str + {:name s/Str (opt :description) s/Str - (opt :externalDocs) ExternalDocumentation - }) + (opt :externalDocs) ExternalDocumentation}) (s/defschema SecuritySchemeApiKey - { - :type s/Any + {:type s/Any (opt :description) s/Str :name s/Str - :in s/Any - }) + :in s/Any}) (s/defschema SecuritySchemeHttp - { - :type s/Any + {:type s/Any (opt :description) s/Str :scheme s/Str - :bearerFormat s/Str - }) + :bearerFormat s/Str}) (s/defschema SecurityScheme - (s/conditional (every-pred map? #(= (:type %) "apiKey")) SecuritySchemeApiKey :else SecuritySchemeHttp)) + (s/conditional + #(and (map? %) (= "apiKey" (:type %))) SecuritySchemeApiKey + :else SecuritySchemeHttp)) (s/defschema Components - { - (opt :schemas) {s/Str OpenApiSchemaPart} + {(opt :schemas) {s/Str OpenApiSchemaPart} (opt :responses) {s/Str Response} (opt :parameters) {s/Str Parameter} (opt :examples) {s/Str Example} @@ -171,17 +149,14 @@ (opt :headers) {s/Str Header} (opt :securitySchemes) {s/Str SecurityScheme} (opt :links) {s/Str Link} - (opt :callbacks) {s/Str Callback} - }) + (opt :callbacks) {s/Str Callback}}) (s/defschema OpenApi - { - (opt :openapi) (s/conditional string? (s/pred #(re-matches #"^3\.\d\.\d$" %))) - (opt :info) Info - (opt :servers) [Server] - (opt :paths) {s/Str Path} - (opt :components) Components - (opt :security) {s/Str [s/Str]} - (opt :tags) [Tag] - (opt :externalDocs) ExternalDocumentation - }) + {(opt :openapi) (s/conditional string? (s/pred #(re-matches #"^3\.\d\.\d$" %))) + (opt :info) Info + (opt :servers) [Server] + (opt :paths) {s/Str Path} + (opt :components) Components + (opt :security) {s/Str [s/Str]} + (opt :tags) [Tag] + (opt :externalDocs) ExternalDocumentation})