git.iko.soy/typeable/openapi3
on bb1c64f help sign in
typeable/openapi3/test/Data/OpenApiSpec.hs
956 lines 27 kB history raw
1{-# LANGUAGE OverloadedLists #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE QuasiQuotes #-}
5module Data.OpenApiSpec where
7import Prelude ()
8import Prelude.Compat
10import Control.Lens
12import Data.Aeson
13import Data.Aeson.QQ.Simple
14import Data.HashMap.Strict (HashMap)
15import qualified Data.HashSet.InsOrd as InsOrdHS
16import Data.Proxy
17import Data.Text (Text)
19import Data.OpenApi
20import Data.OpenApi.Internal
21import SpecCommon
22import Test.Hspec hiding (example)
24spec :: Spec
25spec = do
26 describe "License Object" $ licenseExample <=> licenseExampleJSON
27 describe "Contact Object" $ contactExample <=> contactExampleJSON
28 describe "Info Object" $ infoExample <=> infoExampleJSON
29 describe "Operation Object" $ operationExample <=> operationExampleJSON
30 describe "Schema Object" $ do
31 context "Primitive Sample" $ schemaPrimitiveExample <=> schemaPrimitiveExampleJSON
32 context "Simple Model" $ schemaSimpleModelExample <=> schemaSimpleModelExampleJSON
33 context "Model with Map/Dictionary Properties" $ schemaModelDictExample <=> schemaModelDictExampleJSON
34 context "Model with Arbitrary Properties" $ schemaAdditionalExample <=> schemaAdditionalExampleJSON
35 context "Model with Example" $ schemaWithExampleExample <=> schemaWithExampleExampleJSON
36 describe "Definitions Object" $ definitionsExample <=> definitionsExampleJSON
37 describe "Parameters Definition Object" $ paramsDefinitionExample <=> paramsDefinitionExampleJSON
38 describe "Responses Definition Object" $ responsesDefinitionExample <=> responsesDefinitionExampleJSON
39 describe "Security Definitions Object" $ securityDefinitionsExample <=> securityDefinitionsExampleJSON
40 describe "OAuth2 Security Definitions with merged Scope" $ oAuth2SecurityDefinitionsExample <=> oAuth2SecurityDefinitionsExampleJSON
41 describe "Composition Schema Example" $ compositionSchemaExample <=> compositionSchemaExampleJSON
42 describe "Swagger Object" $ do
43 context "Example with no paths" $ emptyPathsFieldExample <=> emptyPathsFieldExampleJSON
44 context "Todo Example" $ swaggerExample <=> swaggerExampleJSON
45 context "PetStore Example" $ do
46 it "decodes successfully" $ do
47 fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: OpenApi) -> True; _ -> False)
48 it "roundtrips: fmap toJSON . fromJSON" $ do
49 (toJSON :: OpenApi -> Value) <$> fromJSON petstoreExampleJSON `shouldBe` Success petstoreExampleJSON
50 testJsonIdempotency (Proxy :: Proxy HttpScheme)
52main :: IO ()
53main = hspec spec
55-- =======================================================================
56-- Info object
57-- =======================================================================
59infoExample :: Info
60infoExample = mempty
61 & title .~ "Swagger Sample App"
62 & description ?~ "This is a sample server Petstore server."
63 & termsOfService ?~ "http://swagger.io/terms/"
64 & contact ?~ contactExample
65 & license ?~ licenseExample
66 & version .~ "1.0.1"
68infoExampleJSON :: Value
69infoExampleJSON = [aesonQQ|
71 "title": "Swagger Sample App",
72 "description": "This is a sample server Petstore server.",
73 "termsOfService": "http://swagger.io/terms/",
74 "contact": {
75 "name": "API Support",
76 "url": "http://www.swagger.io/support",
77 "email": "support@swagger.io"
78 },
79 "license": {
80 "name": "Apache 2.0",
81 "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
82 },
83 "version": "1.0.1"
85|]
87-- =======================================================================
88-- Contact object
89-- =======================================================================
91contactExample :: Contact
92contactExample = mempty
93 & name ?~ "API Support"
94 & url ?~ URL "http://www.swagger.io/support"
95 & email ?~ "support@swagger.io"
97contactExampleJSON :: Value
98contactExampleJSON = [aesonQQ|
100 "name": "API Support",
101 "url": "http://www.swagger.io/support",
102 "email": "support@swagger.io"
104|]
106-- =======================================================================
107-- License object
108-- =======================================================================
110licenseExample :: License
111licenseExample = "Apache 2.0"
112 & url ?~ URL "http://www.apache.org/licenses/LICENSE-2.0.html"
114licenseExampleJSON :: Value
115licenseExampleJSON = [aesonQQ|
117 "name": "Apache 2.0",
118 "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
120|]
123-- =======================================================================
124-- Operation object
125-- =======================================================================
127operationExample :: Operation
128operationExample = mempty
129 & tags .~ InsOrdHS.fromList ["pet"]
130 & summary ?~ "Updates a pet in the store with form data"
131 & description ?~ ""
132 & operationId ?~ "updatePetWithForm"
133 & parameters .~ [Inline (mempty
134 & name .~ "petId"
135 & description ?~ "ID of pet that needs to be updated"
136 & required ?~ True
137 & in_ .~ ParamPath
138 & schema ?~ Inline (mempty & type_ ?~ OpenApiString))]
139 & requestBody ?~ Inline (
140 mempty & content . at "application/x-www-form-urlencoded" ?~ (mempty & schema ?~ (Inline (mempty
141 & properties . at "petId" ?~ Inline (mempty
142 & description ?~ "Updated name of the pet"
143 & type_ ?~ OpenApiString)
144 & properties . at "status" ?~ Inline (mempty
145 & description ?~ "Updated status of the pet"
146 & type_ ?~ OpenApiString)))))
147 & at 200 ?~ "Pet updated."
148 & at 405 ?~ "Invalid input"
149 & security .~ [SecurityRequirement [("petstore_auth", ["write:pets", "read:pets"])]]
151operationExampleJSON :: Value
152operationExampleJSON = [aesonQQ|
154 "tags": [
155 "pet"
156 ],
157 "summary": "Updates a pet in the store with form data",
158 "description": "",
159 "operationId": "updatePetWithForm",
160 "parameters": [
161 {
162 "required": true,
163 "schema": {
164 "type": "string"
165 },
166 "in": "path",
167 "name": "petId",
168 "description": "ID of pet that needs to be updated"
169 }
170 ],
171 "requestBody": {
172 "content": {
173 "application/x-www-form-urlencoded": {
174 "schema": {
175 "properties": {
176 "petId": {
177 "type": "string",
178 "description": "Updated name of the pet"
179 },
180 "status": {
181 "type": "string",
182 "description": "Updated status of the pet"
183 }
184 }
185 }
186 }
187 }
188 },
189 "responses": {
190 "200": {
191 "description": "Pet updated."
192 },
193 "405": {
194 "description": "Invalid input"
195 }
196 },
197 "security": [
198 {
199 "petstore_auth": [
200 "write:pets",
201 "read:pets"
202 ]
203 }
204 ]
206|]
208-- =======================================================================
209-- Schema object
210-- =======================================================================
212schemaPrimitiveExample :: Schema
213schemaPrimitiveExample = mempty
214 & type_ ?~ OpenApiString
215 & format ?~ "email"
217schemaPrimitiveExampleJSON :: Value
218schemaPrimitiveExampleJSON = [aesonQQ|
220 "type": "string",
221 "format": "email"
223|]
225schemaSimpleModelExample :: Schema
226schemaSimpleModelExample = mempty
227 & type_ ?~ OpenApiObject
228 & required .~ [ "name" ]
229 & properties .~
230 [ ("name", Inline (mempty & type_ ?~ OpenApiString))
231 , ("address", Ref (Reference "Address"))
232 , ("age", Inline $ mempty
233 & minimum_ ?~ 0
234 & type_ ?~ OpenApiInteger
235 & format ?~ "int32" ) ]
237schemaSimpleModelExampleJSON :: Value
238schemaSimpleModelExampleJSON = [aesonQQ|
239{ "required": [ "name" ],
240 "properties": {
241 "name": {
242 "type": "string"
243 },
244 "address": {
245 "$ref": "#/components/schemas/Address"
246 },
247 "age": {
248 "format": "int32",
249 "minimum": 0,
250 "type": "integer"
251 }
252 },
253 "type": "object"
255|]
257schemaModelDictExample :: Schema
258schemaModelDictExample = mempty
259 & type_ ?~ OpenApiObject
260 & additionalProperties ?~ AdditionalPropertiesSchema (Inline (mempty & type_ ?~ OpenApiString))
262schemaModelDictExampleJSON :: Value
263schemaModelDictExampleJSON = [aesonQQ|
265 "type": "object",
266 "additionalProperties": {
267 "type": "string"
268 }
270|]
272schemaAdditionalExample :: Schema
273schemaAdditionalExample = mempty
274 & type_ ?~ OpenApiObject
275 & additionalProperties ?~ AdditionalPropertiesAllowed True
277schemaAdditionalExampleJSON :: Value
278schemaAdditionalExampleJSON = [aesonQQ|
280 "type": "object",
281 "additionalProperties": true
283|]
285schemaWithExampleExample :: Schema
286schemaWithExampleExample = mempty
287 & type_ ?~ OpenApiObject
288 & properties .~
289 [ ("id", Inline $ mempty
290 & type_ ?~ OpenApiInteger
291 & format ?~ "int64" )
292 , ("name", Inline $ mempty
293 & type_ ?~ OpenApiString) ]
294 & required .~ [ "name" ]
295 & example ?~ [aesonQQ|
296 {
297 "name": "Puma",
298 "id": 1
299 }
300 |]
302schemaWithExampleExampleJSON :: Value
303schemaWithExampleExampleJSON = [aesonQQ|
305 "type": "object",
306 "properties": {
307 "id": {
308 "type": "integer",
309 "format": "int64"
310 },
311 "name": {
312 "type": "string"
313 }
314 },
315 "required": [
316 "name"
317 ],
318 "example": {
319 "name": "Puma",
320 "id": 1
321 }
323|]
325-- =======================================================================
326-- Definitions object
327-- =======================================================================
329definitionsExample :: HashMap Text Schema
330definitionsExample =
331 [ ("Category", mempty
332 & type_ ?~ OpenApiObject
333 & properties .~
334 [ ("id", Inline $ mempty
335 & type_ ?~ OpenApiInteger
336 & format ?~ "int64")
337 , ("name", Inline (mempty & type_ ?~ OpenApiString)) ] )
338 , ("Tag", mempty
339 & type_ ?~ OpenApiObject
340 & properties .~
341 [ ("id", Inline $ mempty
342 & type_ ?~ OpenApiInteger
343 & format ?~ "int64")
344 , ("name", Inline (mempty & type_ ?~ OpenApiString)) ] ) ]
346definitionsExampleJSON :: Value
347definitionsExampleJSON = [aesonQQ|
349 "Category": {
350 "type": "object",
351 "properties": {
352 "id": {
353 "type": "integer",
354 "format": "int64"
355 },
356 "name": {
357 "type": "string"
358 }
359 }
360 },
361 "Tag": {
362 "type": "object",
363 "properties": {
364 "id": {
365 "type": "integer",
366 "format": "int64"
367 },
368 "name": {
369 "type": "string"
370 }
371 }
372 }
374|]
376-- =======================================================================
377-- Parameters Definition object
378-- =======================================================================
380paramsDefinitionExample :: HashMap Text Param
381paramsDefinitionExample =
382 [ ("skipParam", mempty
383 & name .~ "skip"
384 & description ?~ "number of items to skip"
385 & required ?~ True
386 & in_ .~ ParamQuery
387 & schema ?~ Inline (mempty
388 & type_ ?~ OpenApiInteger
389 & format ?~ "int32" ))
390 , ("limitParam", mempty
391 & name .~ "limit"
392 & description ?~ "max records to return"
393 & required ?~ True
394 & in_ .~ ParamQuery
395 & schema ?~ Inline (mempty
396 & type_ ?~ OpenApiInteger
397 & format ?~ "int32" )) ]
399paramsDefinitionExampleJSON :: Value
400paramsDefinitionExampleJSON = [aesonQQ|
402 "skipParam": {
403 "name": "skip",
404 "in": "query",
405 "description": "number of items to skip",
406 "required": true,
407 "schema": {
408 "type": "integer",
409 "format": "int32"
410 }
411 },
412 "limitParam": {
413 "name": "limit",
414 "in": "query",
415 "description": "max records to return",
416 "required": true,
417 "schema": {
418 "type": "integer",
419 "format": "int32"
420 }
421 }
423|]
425-- =======================================================================
426-- Responses Definition object
427-- =======================================================================
429responsesDefinitionExample :: HashMap Text Response
430responsesDefinitionExample =
431 [ ("NotFound", mempty & description .~ "Entity not found.")
432 , ("IllegalInput", mempty & description .~ "Illegal input for operation.") ]
434responsesDefinitionExampleJSON :: Value
435responsesDefinitionExampleJSON = [aesonQQ|
437 "NotFound": {
438 "description": "Entity not found."
439 },
440 "IllegalInput": {
441 "description": "Illegal input for operation."
442 }
444|]
446-- =======================================================================
447-- Responses Definition object
448-- =======================================================================
450securityDefinitionsExample :: SecurityDefinitions
451securityDefinitionsExample = SecurityDefinitions
452 [ ("api_key", SecurityScheme
453 { _securitySchemeType = SecuritySchemeApiKey (ApiKeyParams "api_key" ApiKeyHeader)
454 , _securitySchemeDescription = Nothing })
455 , ("petstore_auth", SecurityScheme
456 { _securitySchemeType = SecuritySchemeOAuth2 (mempty & implicit ?~ OAuth2Flow
457 { _oAuth2Params = OAuth2ImplicitFlow "http://swagger.io/api/oauth/dialog"
458 , _oAath2RefreshUrl = Nothing
459 , _oAuth2Scopes =
460 [ ("write:pets", "modify pets in your account")
461 , ("read:pets", "read your pets") ] } )
462 , _securitySchemeDescription = Nothing })
463 , ("basic", SecurityScheme
464 { _securitySchemeType = SecuritySchemeHttp Basic
465 , _securitySchemeDescription = Nothing })]
467securityDefinitionsExampleJSON :: Value
468securityDefinitionsExampleJSON = [aesonQQ|
470 "api_key": {
471 "in": "header",
472 "name": "api_key",
473 "type": "apiKey"
474 },
475 "petstore_auth": {
476 "type": "oauth2",
477 "flows": {
478 "implicit": {
479 "scopes": {
480 "write:pets": "modify pets in your account",
481 "read:pets": "read your pets"
482 },
483 "authorizationUrl": "http://swagger.io/api/oauth/dialog"
484 }
485 }
486 },
487 "basic": {
488 "type": "http",
489 "scheme": "Basic"
490 }
493|]
495oAuth2SecurityDefinitionsReadExample :: SecurityDefinitions
496oAuth2SecurityDefinitionsReadExample = SecurityDefinitions
497 [ ("petstore_auth", SecurityScheme
498 { _securitySchemeType = SecuritySchemeOAuth2 (mempty & implicit ?~ OAuth2Flow
499 { _oAuth2Params = OAuth2ImplicitFlow "http://swagger.io/api/oauth/dialog"
500 , _oAath2RefreshUrl = Nothing
501 , _oAuth2Scopes =
502 [ ("read:pets", "read your pets") ] } )
503 , _securitySchemeDescription = Nothing })
504 ]
506oAuth2SecurityDefinitionsWriteExample :: SecurityDefinitions
507oAuth2SecurityDefinitionsWriteExample = SecurityDefinitions
508 [ ("petstore_auth", SecurityScheme
509 { _securitySchemeType = SecuritySchemeOAuth2 (mempty & implicit ?~ OAuth2Flow
510 { _oAuth2Params = OAuth2ImplicitFlow "http://swagger.io/api/oauth/dialog"
511 , _oAath2RefreshUrl = Nothing
512 , _oAuth2Scopes =
513 [ ("write:pets", "modify pets in your account") ] } )
514 , _securitySchemeDescription = Nothing })
515 ]
517oAuth2SecurityDefinitionsExample :: SecurityDefinitions
518oAuth2SecurityDefinitionsExample =
519 oAuth2SecurityDefinitionsWriteExample <>
520 oAuth2SecurityDefinitionsReadExample
522oAuth2SecurityDefinitionsExampleJSON :: Value
523oAuth2SecurityDefinitionsExampleJSON = [aesonQQ|
525 "petstore_auth": {
526 "type": "oauth2",
527 "flows": {
528 "implicit": {
529 "scopes": {
530 "write:pets": "modify pets in your account",
531 "read:pets": "read your pets"
532 },
533 "authorizationUrl": "http://swagger.io/api/oauth/dialog"
534 }
535 }
536 }
538|]
540-- =======================================================================
541-- Swagger object
542-- =======================================================================
544emptyPathsFieldExample :: OpenApi
545emptyPathsFieldExample = mempty
547emptyPathsFieldExampleJSON :: Value
548emptyPathsFieldExampleJSON = [aesonQQ|
550 "openapi": "3.0.0",
551 "info": {"version": "", "title": ""},
552 "paths": {},
553 "components": {}
555|]
557swaggerExample :: OpenApi
558swaggerExample = mempty
559 -- & basePath ?~ "/"
560 -- & schemes ?~ [Http]
561 & info .~ (mempty
562 & version .~ "1.0"
563 & title .~ "Todo API"
564 & license ?~ "MIT"
565 & license._Just.url ?~ URL "http://mit.com"
566 & description ?~ "This is an API that tests servant-swagger support for a Todo API")
567 & paths.at "/todo/{id}" ?~ (mempty & get ?~ ((mempty :: Operation)
568 & responses . at 200 ?~ Inline (mempty
569 & description .~ "OK"
570 & content . at "application/json" ?~ (mempty
571 & schema ?~ Inline (mempty
572 & type_ ?~ OpenApiObject
573 & example ?~ [aesonQQ|
574 {
575 "created": 100,
576 "description": "get milk"
577 } |]
578 & description ?~ "This is some real Todo right here"
579 & properties .~
580 [ ("created", Inline $ mempty
581 & type_ ?~ OpenApiInteger
582 & format ?~ "int32")
583 , ("description", Inline (mempty & type_ ?~ OpenApiString))])))
584 & parameters .~
585 [ Inline $ mempty
586 & required ?~ True
587 & name .~ "id"
588 & description ?~ "TodoId param"
589 & in_ .~ ParamPath
590 & schema ?~ Inline (mempty
591 & type_ ?~ OpenApiString ) ]
592 & tags .~ InsOrdHS.fromList [ "todo" ] ))
594swaggerExampleJSON :: Value
595swaggerExampleJSON = [aesonQQ|
597 "openapi": "3.0.0",
598 "info": {
599 "version": "1.0",
600 "title": "Todo API",
601 "license": {
602 "url": "http://mit.com",
603 "name": "MIT"
604 },
605 "description": "This is an API that tests servant-swagger support for a Todo API"
606 },
607 "paths": {
608 "/todo/{id}": {
609 "get": {
610 "tags": [
611 "todo"
612 ],
613 "parameters": [
614 {
615 "required": true,
616 "schema": {
617 "type": "string"
618 },
619 "in": "path",
620 "name": "id",
621 "description": "TodoId param"
622 }
623 ],
624 "responses": {
625 "200": {
626 "content": {
627 "application/json": {
628 "schema": {
629 "example": {
630 "created": 100,
631 "description": "get milk"
632 },
633 "type": "object",
634 "description": "This is some real Todo right here",
635 "properties": {
636 "created": {
637 "format": "int32",
638 "type": "integer"
639 },
640 "description": {
641 "type": "string"
642 }
643 }
644 }
645 }
646 },
647 "description": "OK"
648 }
649 }
650 }
651 }
652 },
653 "components": {}
655|]
657petstoreExampleJSON :: Value
658petstoreExampleJSON = [aesonQQ|
660 "openapi": "3.0.0",
661 "info": {
662 "version": "1.0.0",
663 "title": "Swagger Petstore",
664 "license": {
665 "name": "MIT"
666 }
667 },
668 "servers": [
669 {
670 "url": "http://petstore.swagger.io/v1"
671 }
672 ],
673 "paths": {
674 "/pets": {
675 "get": {
676 "summary": "List all pets",
677 "operationId": "listPets",
678 "tags": [
679 "pets"
680 ],
681 "parameters": [
682 {
683 "name": "limit",
684 "in": "query",
685 "description": "How many items to return at one time (max 100)",
686 "required": false,
687 "schema": {
688 "type": "integer",
689 "format": "int32"
690 }
691 }
692 ],
693 "responses": {
694 "200": {
695 "description": "A paged array of pets",
696 "headers": {
697 "x-next": {
698 "description": "A link to the next page of responses",
699 "schema": {
700 "type": "string"
701 }
702 }
703 },
704 "content": {
705 "application/json": {
706 "schema": {
707 "type": "array",
708 "items": {
709 "type": "object",
710 "required": [
711 "id",
712 "name"
713 ],
714 "properties": {
715 "id": {
716 "type": "integer",
717 "format": "int64"
718 },
719 "name": {
720 "type": "string"
721 },
722 "tag": {
723 "type": "string"
724 }
725 }
726 }
727 }
728 }
729 }
730 },
731 "default": {
732 "description": "unexpected error",
733 "content": {
734 "application/json": {
735 "schema": {
736 "type": "object",
737 "required": [
738 "code",
739 "message"
740 ],
741 "properties": {
742 "code": {
743 "type": "integer",
744 "format": "int32"
745 },
746 "message": {
747 "type": "string"
748 }
749 }
750 }
751 }
752 }
753 }
754 }
755 },
756 "post": {
757 "summary": "Create a pet",
758 "operationId": "createPets",
759 "tags": [
760 "pets"
761 ],
762 "responses": {
763 "201": {
764 "description": "Null response"
765 },
766 "default": {
767 "description": "unexpected error",
768 "content": {
769 "application/json": {
770 "schema": {
771 "type": "object",
772 "required": [
773 "code",
774 "message"
775 ],
776 "properties": {
777 "code": {
778 "type": "integer",
779 "format": "int32"
780 },
781 "message": {
782 "type": "string"
783 }
784 }
785 }
786 }
787 }
788 }
789 }
790 }
791 },
792 "/pets/{petId}": {
793 "get": {
794 "summary": "Info for a specific pet",
795 "operationId": "showPetById",
796 "tags": [
797 "pets"
798 ],
799 "parameters": [
800 {
801 "name": "petId",
802 "in": "path",
803 "required": true,
804 "description": "The id of the pet to retrieve",
805 "schema": {
806 "type": "string"
807 }
808 }
809 ],
810 "responses": {
811 "200": {
812 "description": "Expected response to a valid request",
813 "content": {
814 "application/json": {
815 "schema": {
816 "type": "object",
817 "required": [
818 "id",
819 "name"
820 ],
821 "properties": {
822 "id": {
823 "type": "integer",
824 "format": "int64"
825 },
826 "name": {
827 "type": "string"
828 },
829 "tag": {
830 "type": "string"
831 }
832 }
833 }
834 }
835 }
836 },
837 "default": {
838 "description": "unexpected error",
839 "content": {
840 "application/json": {
841 "schema": {
842 "type": "object",
843 "required": [
844 "code",
845 "message"
846 ],
847 "properties": {
848 "code": {
849 "type": "integer",
850 "format": "int32"
851 },
852 "message": {
853 "type": "string"
854 }
855 }
856 }
857 }
858 }
859 }
860 }
861 }
862 }
863 },
864 "components": {
865 "schemas": {
866 "Pet": {
867 "type": "object",
868 "required": [
869 "id",
870 "name"
871 ],
872 "properties": {
873 "id": {
874 "type": "integer",
875 "format": "int64"
876 },
877 "name": {
878 "type": "string"
879 },
880 "tag": {
881 "type": "string"
882 }
883 }
884 },
885 "Pets": {
886 "type": "array",
887 "items": {
888 "type": "object",
889 "required": [
890 "id",
891 "name"
892 ],
893 "properties": {
894 "id": {
895 "type": "integer",
896 "format": "int64"
897 },
898 "name": {
899 "type": "string"
900 },
901 "tag": {
902 "type": "string"
903 }
904 }
905 }
906 },
907 "Error": {
908 "type": "object",
909 "required": [
910 "code",
911 "message"
912 ],
913 "properties": {
914 "code": {
915 "type": "integer",
916 "format": "int32"
917 },
918 "message": {
919 "type": "string"
920 }
921 }
922 }
923 }
924 }
926|]
928compositionSchemaExample :: Schema
929compositionSchemaExample = mempty
930 & type_ ?~ OpenApiObject
931 & Data.OpenApi.allOf ?~ [
932 Ref (Reference "Other")
933 , Inline (mempty
934 & type_ ?~ OpenApiObject
935 & properties .~
936 [ ("greet", Inline $ mempty
937 & type_ ?~ OpenApiString) ])
938 ]
940compositionSchemaExampleJSON :: Value
941compositionSchemaExampleJSON = [aesonQQ|
943 "type": "object",
944 "allOf": [
945 {
946 "$ref": "#/components/schemas/Other"
947 },
948 {
949 "type": "object",
950 "properties": {
951 "greet": { "type": "string" }
952 }
953 }
954 ]
956|]