git.iko.soy/typeable/mock-server-client
on master help sign in
18 files changed+515−325
since splitsnapshots
unifiedsplit
.github/workflows/haskell-ci.yml+25 .gitignore+2 README.md+77−33 codegen/mock-server-openapi.yaml+257−269 ghc-9.0.2.yaml+8 ghc-9.0.2.yaml.lock+12 ghc-9.2.5.yaml+8 ghc-9.2.5.yaml.lock+12 mock-server-client.cabal+3 src/MockServer.hs+2 src/MockServer/Common.hs+23−5 src/MockServer/Operations/Put_mockserver_retrieve.hs+2−2 src/MockServer/Types.hs+2 src/MockServer/Types/HttpRequest.hs+7−3 src/MockServer/Types/JsonSchemaBodyMatcher.hs+6−6 src/MockServer/Types/Protocol.hs+53 src/MockServer/Types/Protocol.hs-boot+9 src/MockServer/Types/StringOrJsonSchema.hs+7−7
.github/workflows/haskell-ci.ymlnew file+25
@@ -0,0 +1,25 @@
1+name: Haskell-CI
2+on: [push]
3+jobs:
4+ linux:
5+ name: GHC-${{ matrix.ghc-version }}
6+ runs-on: ubuntu-latest
7+ strategy:
8+ matrix:
9+ ghc-version:
10+ - 9.0.2
11+ - 9.2.5
12+ steps:
13+ - uses: actions/checkout@v3
14+ - uses: haskell/actions/setup@v2
15+ with:
16+ enable-stack: true
17+ ghc-version: ${{ matrix.ghc-version }}
18+ stack-version: 'latest'
19+ - uses: actions/cache@v3
20+ with:
21+ path: |
22+ ~/.stack
23+ ./.stack-work
24+ key: ${{ matrix.ghc-version }}
25+ - run: stack --stack-yaml ghc-${{ matrix.ghc-version }}.yaml --install-ghc test --fast --haddock
.gitignorenew file+2
@@ -0,0 +1,2 @@
1+.stack-work
2+TAGS
README.md+77−33
@@ -1,52 +1,96 @@
1−## About
1+# About
22
33The package is the client library for the [mock server](https://www.mock-server.com/). The source code is
44generated by the [openapi3-code-generator](https://hackage.haskell.org/package/openapi3-code-generator), specifically its patched version.
55
6−## How to regenerate
6+## Usage
77
8−```
9−cd codegen && ./regen.sh
10−```
8+``` haskell
9+module Main
1110
12−It requires the `nix` to be installed in your system because it uses the
13−`openapi3-code-generator` built by the `nix`.
11+import MockServer as Mock
12+import Network.HTTP.Client
1413
15−After regeneration you will see some `.hs` files changed. This is because some
16−parts of the libary are modified by hand to make the more usable.
14+conf :: Mock.Configuration
15+conf = Configuration
16+ { configBaseURL = "http://localhost"
17+ , configSecurityScheme = id
18+ , configIncludeUserAgent = False
19+ , configApplicationName = "ping-app" }
20+
21+expectation :: Mock.Expectations
22+expectation = Mock.ExpectationsExpectation $ Mock.mkExpectation
23+ { expectationHttpRequest = Just request
24+ , expectationHttpResponse = Just response }
25+ where
26+ request = Mock.mkHttpRequest
27+ { httpRequestMethod = Just $ StringOrJsonSchemaText "POST"
28+ , httpRequestPath = Just $ StringOrJsonSchemaText "/ping" }
29+ response = Mock.mkHttpResponse
30+ { httpResponseBody = Just $ BodyWithContentTypeRawStringResponseBody "pong"
31+ , httpResponseStatusCode = Just 200 }
32+
33+-- | Puts the expectation which will response with "pong" body to the "POST /ping" request
34+main :: IO ()
35+main = do
36+ void $ Mock.runWithConfiguration conf $ Mock.put_mockserver_expectation expectation
37+```
38+
39+# Maintainance
1740
1841## Files
1942
2043### The `codegen` dir
2144
2245* `regen.sh` is the simple script to regenerate the whole package.
23−* `shell.nix` a shell in which the `regen.sh` calls the `openapi3-code-generator` to regenerate the
24−* `mock-server-openapi-5.13.x-swagger.yaml` not the original file as you might
25− think. The thing is that the `openapi3-code-generator` does not support all
26− the features of the OpenAPI3 standard correctly, so it is
27− hand-postprocessed. It was originally downloaded from [here](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.13.x) and fixed.
28−* `src` contails the generted code, but not exactly. Some of the parts of the
29− generted code was not very pleasant, so it was fixed too.
46+* `shell.nix` a shell in which the `regen.sh` calls the `openapi3-code-generator` to regenerate the code
47+* `mock-server-openapi.yaml` not the [original specification](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi) of the `mock-server` as you might
48+ think. The thing is that the `openapi3-code-generator` does not support all the features of the
49+ OpenAPI3 standard correctly, so it is hand-postprocessed. It was originally downloaded from
50+ [here](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.13.x) and fixed.
51+
52+### Other
3053
31−### What will happen if you just call the `regen.sh`?
54+* `src` and `mock-server-client.cabal` contain the generted code, but not exactly. Some of the parts
55+ of the generted code was not very pleasant, so it was fixed too.
56+
57+## What will happen if you just call the `regen.sh`?
3258
3359It will build the `openapi3-code-generator` in `nix` and regenerate the whole
3460Haskell source code. You will see that the code was changed, because as
3561mentioned earlier the original code was slightly modified, so watch your commits.
3662
37−## How the to update the package to the new version of the `mock-server`?
38−
39−* Commit all changes in git
40−* Run the `regen.sh` and regenerate the whole package
41−* Run `git diff -p > src.patch` and save the manual changes made to the source code
42−* Download the [original spec](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.13.x) in place of our patched spec file
43−* Run the `git diff -- codegen/mock-server-openapi-5.13.x-swagger.yaml -p > spec.patch`
44−* Download the [new spec](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi) and put it in place of the old one
45−* Try to `git apply spec.patch` to the newer version of the spec to apply manual
46− changes to the new spec. If somethig goes wrong use AI to fix it for you, heh.
47−* Fix the `regen.sh` and rename the `mock-server-openapi-5.13.x-swagger.yaml` to
48− the newer version.
49−* `git commit -m 'dangerous action'`
50−* Run the `regen.sh` so you will hopefuly have a new version of the client code
51− generated.
52−* `git apply src.patch` to apply manual patches to the new version.
63+## How to update the package to the new version of the `mock-server` spec?
64+
65+* Commit or discard all changes
66+* `git checkout update-openapi-spec`
67+* Replace the `codegen/mock-server-openapi.yaml` with a newer version
68+* `git commit -m "updated mock-server-openapi.yaml to version $NEWVERSION"`
69+* `git checkout -b "update-$NEWVERSION" master`
70+* `git merge update-openapi-spec`
71+* Resolve conflicts if any
72+* `./codegen/regen.sh`
73+* `git symbolic-ref HEAD refs/heads/update-generated-code && git reset`
74+ switching to the branch `update-generated-code` without checking out the working-tree
75+* `git commit -m "update the generted code for version $NEWVERSION"`
76+* `git checkout "update-$NEWVERSION"`
77+* `git merge update-generated-code`
78+* Resolve conflicts if any
79+* `git push origin "update-$NEWVERSION"`
80+* Create PR, wait for CI, review, merge into the master
81+
82+The algorithm is kind of weird, but for a reason.
83+
84+The branch `update-openapi-spec` is the branch tracking only original
85+`codegen/mock-server-openapi.yaml` changes, meaning changes made by authors of the
86+`mock-server`. So, when you merge changes of this branch into the master you literally merge the
87+changes made by authors of the `mock-server` with our manual changes made to please the
88+`openapi3-code-generator`.
89+
90+The bratch `update-generated-code` is for tracking "changes" made by the code generator when it is
91+feed by the new OpenAPI spec file. So, when you merge this branch into the master you literally
92+merge the "code regeneration patch" with changes made by hand.
93+
94+The `master` branch is for manual changes only. The changes made to keep things working and the
95+package usable. You can always see the manual changes just by `git diff update-generated-code
96+master` or `git diff update-openapi-spec master`
codegen/mock-server-openapi.yaml+257−269
@@ -4,7 +4,7 @@ servers:
44 - url: 'https://localhost:1080/'
55info:
66 title: MockServer API
7− version: 5.13.x
7+ version: 5.15.x
88 description: >-
99 MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below).
1010
@@ -18,7 +18,7 @@ info:
1818 name: Apache 2.0
1919tags:
2020 - name: expectation
21− description: Create or update expectations - updates if the id matches an existing expecations (only supported by MockServer)
21+ description: Create or update expectations - updates if the id matches an existing expectations (only supported by MockServer)
2222 - name: verify
2323 description: Verify requests (both MockServer & MockServer Proxy)
2424 - name: control
@@ -36,7 +36,7 @@ paths:
3636 content:
3737 application/json:
3838 schema:
39− description: "list of upserted expectations"
39+ title: list of upserted expectations
4040 type: array
4141 additionalProperties: false
4242 items:
@@ -63,7 +63,7 @@ paths:
6363 content:
6464 application/json:
6565 schema:
66− description: "list of upserted expectations"
66+ title: list of upserted expectations
6767 type: array
6868 additionalProperties: false
6969 items:
@@ -89,15 +89,6 @@ paths:
8989 description: expectations and recorded requests cleared
9090 '400':
9191 description: incorrect request format
92− parameters:
93− - in: query
94− name: type
95− schema:
96− type: string
97− enum: ["all", "log", "expectations"]
98− default: "all"
99− required: false
100− description: specifies the type of information to clear, default if not specified is "all", supported values are "all", "log", "expectations"
10192 requestBody:
10293 content:
10394 application/json:
@@ -105,7 +96,7 @@ paths:
10596 oneOf:
10697 - $ref: "#/components/schemas/RequestDefinition"
10798 - $ref: "#/components/schemas/ExpectationId"
108− description: request used to match expectations and recored requests to clear
99+ description: request used to match expectations and record requests to clear
109100 /mockserver/reset:
110101 put:
111102 tags:
@@ -125,14 +116,12 @@ paths:
125116 schema:
126117 type: string
127118 enum: [ "java", "json", "log_entries" ]
128− required: false
129− description: changes response format, default if not specificed is "json", supported values are "java", "json", "log_entries"
119+ description: changes response format, default if not specified is "json", supported values are "java", "json", "log_entries"
130120 - in: query
131121 name: type
132122 schema:
133123 type: string
134124 enum: [ "logs", "requests", "request_responses", "recorded_expectations", "active_expectations" ]
135− required: false
136125 description: specifies the type of object that is retrieve, default if not specified is "requests", supported values are "logs", "requests", "recorded_expectations", "active_expectations"
137126 responses:
138127 '200':
@@ -148,11 +137,7 @@ paths:
148137 - type: array
149138 additionalProperties: false
150139 items:
151− $ref: "#/components/schemas/HttpRequest"
152− - type: array
153− additionalProperties: false
154− items:
155− $ref: "#/components/schemas/HttpRequestAndHttpResponse"
140+ $ref: "#/components/schemas/HttpResponse"
156141 application/java:
157142 schema:
158143 type: string
@@ -272,7 +257,7 @@ paths:
272257components:
273258 schemas:
274259 Expectations:
275− description: "list of expectations"
260+ title: "list of expectations"
276261 oneOf:
277262 - $ref: "#/components/schemas/Expectation"
278263 - type: array
@@ -280,7 +265,7 @@ components:
280265 items:
281266 $ref: "#/components/schemas/Expectation"
282267 Expectation:
283− description: "expectation"
268+ title: "expectation"
284269 type: object
285270 additionalProperties: false
286271 properties:
@@ -290,6 +275,8 @@ components:
290275 type: integer
291276 httpRequest:
292277 $ref: "#/components/schemas/RequestDefinition"
278+ openAPIDefinition:
279+ $ref: "#/components/schemas/OpenAPIDefinition"
293280 httpResponse:
294281 $ref: "#/components/schemas/HttpResponse"
295282 httpResponseTemplate:
@@ -314,29 +301,8 @@ components:
314301 $ref: "#/components/schemas/Times"
315302 timeToLive:
316303 $ref: "#/components/schemas/TimeToLive"
317− oneOf:
318− - required:
319− - httpResponse
320− - required:
321− - httpResponseTemplate
322− - required:
323− - httpResponseClassCallback
324− - required:
325− - httpResponseObjectCallback
326− - required:
327− - httpForward
328− - required:
329− - httpForwardTemplate
330− - required:
331− - httpForwardClassCallback
332− - required:
333− - httpForwardObjectCallback
334− - required:
335− - httpOverrideForwardedRequest
336− - required:
337− - httpError
338304 ExpectationId:
339− description: "pointer to existing expectation"
305+ title: "pointer to existing expectation"
340306 type: object
341307 additionalProperties: false
342308 properties:
@@ -345,7 +311,7 @@ components:
345311 required:
346312 - id
347313 OpenAPIExpectations:
348− description: "list of open api expectations"
314+ title: "list of open api expectations"
349315 oneOf:
350316 - $ref: "#/components/schemas/OpenAPIExpectation"
351317 - type: array
@@ -353,7 +319,7 @@ components:
353319 items:
354320 $ref: "#/components/schemas/OpenAPIExpectation"
355321 OpenAPIExpectation:
356− description: "open api or swagger expectation"
322+ title: "open api or swagger expectation"
357323 type: object
358324 additionalProperties: false
359325 properties:
@@ -368,12 +334,12 @@ components:
368334 required:
369335 - specUrlOrPayload
370336 RequestDefinition:
371− description: "request definition"
337+ title: "request definition"
372338 oneOf:
373339 - $ref: "#/components/schemas/HttpRequest"
374340 - $ref: "#/components/schemas/OpenAPIDefinition"
375341 HttpRequest:
376− description: "request properties matcher"
342+ title: "request properties matcher"
377343 type: object
378344 additionalProperties: false
379345 properties:
@@ -397,8 +363,10 @@ components:
397363 $ref: "#/components/schemas/KeyToValue"
398364 socketAddress:
399365 $ref: "#/components/schemas/SocketAddress"
366+ protocol:
367+ $ref: "#/components/schemas/Protocol"
400368 OpenAPIDefinition:
401− description: "open api or swagger request matcher"
369+ title: "open api or swagger request matcher"
402370 type: object
403371 additionalProperties: false
404372 properties:
@@ -407,7 +375,7 @@ components:
407375 operationId:
408376 type: string
409377 HttpResponse:
410− description: "response to return"
378+ title: "response to return"
411379 type: object
412380 additionalProperties: false
413381 properties:
@@ -426,7 +394,7 @@ components:
426394 reasonPhrase:
427395 type: string
428396 HttpTemplate:
429− description: "template to generate response / request"
397+ title: "template to generate response / request"
430398 type: object
431399 additionalProperties: false
432400 properties:
@@ -440,7 +408,7 @@ components:
440408 template:
441409 type: string
442410 HttpForward:
443− description: "host and port to forward to"
411+ title: host and port to forward to
444412 type: object
445413 additionalProperties: false
446414 properties:
@@ -455,7 +423,7 @@ components:
455423 - HTTP
456424 - HTTPS
457425 HttpClassCallback:
458− description: "class callback"
426+ title: class callback
459427 type: object
460428 additionalProperties: false
461429 properties:
@@ -464,7 +432,7 @@ components:
464432 callbackClass:
465433 type: string
466434 HttpObjectCallback:
467− description: "object / method callback"
435+ title: object / method callback
468436 type: object
469437 additionalProperties: false
470438 properties:
@@ -475,7 +443,7 @@ components:
475443 responseCallback:
476444 type: boolean
477445 HttpOverrideForwardedRequest:
478− description: "override forwarded request"
446+ title: override forwarded request
479447 oneOf:
480448 - type: object
481449 additionalProperties: false
@@ -577,7 +545,7 @@ components:
577545 httpResponse:
578546 "$ref": "#/components/schemas/HttpResponse"
579547 HttpError:
580− description: "error behaviour"
548+ title: error behaviour
581549 type: object
582550 additionalProperties: false
583551 properties:
@@ -588,7 +556,7 @@ components:
588556 responseBytes:
589557 type: string
590558 Times:
591− description: "number of responses"
559+ title: "number of responses"
592560 type: object
593561 additionalProperties: false
594562 properties:
@@ -597,7 +565,7 @@ components:
597565 unlimited:
598566 type: boolean
599567 TimeToLive:
600− description: "time expectation is valid for"
568+ title: "time expectation is valid for"
601569 type: object
602570 additionalProperties: false
603571 properties:
@@ -687,7 +655,7 @@ components:
687655 # "^\\S+$":
688656 # $ref: "#/components/schemas/StringOrJsonSchema"
689657 StringOrJsonSchema:
690− description: "string value that can be support nottable, optional or a json schema"
658+ title: string value that can be support nottable, optional or a json schema
691659 oneOf:
692660 - type: string
693661 - type: object
@@ -718,7 +686,7 @@ components:
718686 - PIPE_DELIMITED
719687 - DEEP_OBJECT
720688 SocketAddress:
721− description: "remote address to send request to, only used for request overrides"
689+ title: remote address to send request to
722690 type: object
723691 additionalProperties: false
724692 properties:
@@ -730,198 +698,239 @@ components:
730698 enum:
731699 - HTTP
732700 - HTTPS
701+ BinaryBodyMatcher:
702+ type: object
703+ description: "binary body matcher"
704+ additionalProperties: false
705+ properties:
706+ not:
707+ type: boolean
708+ type:
709+ enum:
710+ - BINARY
711+ base64Bytes:
712+ type: string
713+ contentType:
714+ type: string
715+ JsonBodyMatcher:
716+ type: object
717+ description: "json body matcher"
718+ additionalProperties: false
719+ properties:
720+ not:
721+ type: boolean
722+ type:
723+ enum:
724+ - JSON
725+ json:
726+ type: string
727+ contentType:
728+ type: string
729+ matchType:
730+ enum:
731+ - STRICT
732+ - ONLY_MATCHING_FIELDS
733+ RawJsonBodyMatcher:
734+ type: object
735+ description: "json matching fields body matcher"
736+ additionalProperties: true
737+ JsonSchemaBodyMatcher:
738+ type: object
739+ description: "json schema body matcher"
740+ additionalProperties: false
741+ properties:
742+ not:
743+ type: boolean
744+ type:
745+ enum:
746+ - JSON_SCHEMA
747+ jsonSchema:
748+ $ref: http://json-schema.org/draft-04/schema
749+ JsonPathBodyMatcher:
750+ type: object
751+ description: "JSON path body matcher"
752+ additionalProperties: false
753+ properties:
754+ not:
755+ type: boolean
756+ type:
757+ enum:
758+ - JSON_PATH
759+ jsonPath:
760+ type: string
761+ ParameterBodyMatcher:
762+ type: object
763+ description: "parameter body matcher"
764+ additionalProperties: false
765+ properties:
766+ not:
767+ type: boolean
768+ type:
769+ enum:
770+ - PARAMETERS
771+ parameters:
772+ $ref: "#/components/schemas/KeyToMultiValue"
773+ RegexBodyMatcher:
774+ type: object
775+ description: "regex body matcher"
776+ additionalProperties: false
777+ properties:
778+ not:
779+ type: boolean
780+ type:
781+ enum:
782+ - REGEX
783+ regex:
784+ type: string
785+ StringBodyMatcher:
786+ type: object
787+ description: "string body matcher"
788+ additionalProperties: false
789+ properties:
790+ not:
791+ type: boolean
792+ type:
793+ enum:
794+ - STRING
795+ string:
796+ type: string
797+ contentType:
798+ type: string
799+ subString:
800+ type: boolean
801+ RawStringBodyMatcher:
802+ type: string
803+ description: "substring body matcher"
804+ XmlBodyMatcher:
805+ type: object
806+ description: "xml body matcher"
807+ additionalProperties: false
808+ properties:
809+ not:
810+ type: boolean
811+ type:
812+ enum:
813+ - XML
814+ xml:
815+ type: string
816+ contentType:
817+ type: string
818+ XmlSchemaBodyMatcher:
819+ type: object
820+ description: "xml schema body matcher"
821+ additionalProperties: false
822+ properties:
823+ not:
824+ type: boolean
825+ type:
826+ enum:
827+ - XML_SCHEMA
828+ xmlSchema:
829+ type: string
830+ XpathBodyMatcher:
831+ type: object
832+ description: "xpath body matcher"
833+ additionalProperties: false
834+ properties:
835+ not:
836+ type: boolean
837+ type:
838+ enum:
839+ - XPATH
840+ xpath:
841+ type: string
842+ Protocol:
843+ description: "protocol matcher"
844+ enum:
845+ - HTTP_1_1
846+ - HTTP_2
733847 Body:
734848 description: "request body matcher"
735849 anyOf:
736− - type: object
737− description: "binary body matcher"
738− additionalProperties: false
739− properties:
740− not:
741− type: boolean
742− type:
743− enum:
744− - BINARY
745− base64Bytes:
746− type: string
747− contentType:
748− type: string
749− - type: object
750− description: "json body matcher"
751− additionalProperties: false
752− properties:
753− not:
754− type: boolean
755− type:
756− enum:
757− - JSON
758− json:
759− type: string
760− contentType:
761− type: string
762− matchType:
763− enum:
764− - STRICT
765− - ONLY_MATCHING_FIELDS
766− - type: object
767− description: "json matching fields body matcher"
768− additionalProperties: true
769− - type: object
770− description: "json schema body matcher"
771− additionalProperties: false
772− properties:
773− not:
774− type: boolean
775− type:
776− enum:
777− - JSON_SCHEMA
778− jsonSchema:
779− $ref: http://json-schema.org/draft-04/schema
780− - type: object
781− description: "JSON path body matcher"
782− additionalProperties: false
783− properties:
784− not:
785− type: boolean
786− type:
787− enum:
788− - JSON_PATH
789− jsonPath:
790− type: string
791− - type: object
792− description: "parameter body matcher"
793− additionalProperties: false
794− properties:
795− not:
796− type: boolean
797− type:
798− enum:
799− - PARAMETERS
800− parameters:
801− $ref: "#/components/schemas/KeyToMultiValue"
802− - type: object
803− description: "regex body matcher"
804− additionalProperties: false
805− properties:
806− not:
807− type: boolean
808− type:
809− enum:
810− - REGEX
811− regex:
812− type: string
813− - type: object
814− description: "string body matcher"
815− additionalProperties: false
816− properties:
817− not:
818− type: boolean
819− type:
820− enum:
821− - STRING
822− string:
823− type: string
824− contentType:
825− type: string
826− subString:
827− type: boolean
828− - type: string
829− description: "substring body matcher"
830− - type: object
831− description: "xml body matcher"
832− additionalProperties: false
833− properties:
834− not:
835− type: boolean
836− type:
837− enum:
838− - XML
839− xml:
840− type: string
841− contentType:
842− type: string
843− - type: object
844− description: "xml schema body matcher"
845− additionalProperties: false
846− properties:
847− not:
848− type: boolean
849− type:
850− enum:
851− - XML_SCHEMA
852− xmlSchema:
853− type: string
854− - type: object
855− description: "xpath body matcher"
856− additionalProperties: false
857− properties:
858− not:
859− type: boolean
860− type:
861− enum:
862− - XPATH
863− xpath:
864− type: string
850+ - $ref: "#/components/schemas/BinaryBodyMatcher"
851+ - $ref: "#/components/schemas/JsonBodyMatcher"
852+ - $ref: "#/components/schemas/RawJsonBodyMatcher"
853+ - $ref: "#/components/schemas/JsonSchemaBodyMatcher"
854+ - $ref: "#/components/schemas/JsonPathBodyMatcher"
855+ - $ref: "#/components/schemas/ParameterBodyMatcher"
856+ - $ref: "#/components/schemas/RegexBodyMatcher"
857+ - $ref: "#/components/schemas/StringBodyMatcher"
858+ - $ref: "#/components/schemas/RawStringBodyMatcher"
859+ - $ref: "#/components/schemas/XmlBodyMatcher"
860+ - $ref: "#/components/schemas/XmlSchemaBodyMatcher"
861+ - $ref: "#/components/schemas/XpathBodyMatcher"
862+ BinaryBodyResponse:
863+ type: object
864+ description: "binary response body"
865+ additionalProperties: false
866+ properties:
867+ not:
868+ type: boolean
869+ type:
870+ enum:
871+ - BINARY
872+ base64Bytes:
873+ type: string
874+ contentType:
875+ type: string
876+ JsonResponseBody:
877+ type: object
878+ description: "json response body"
879+ additionalProperties: false
880+ properties:
881+ not:
882+ type: boolean
883+ type:
884+ enum:
885+ - JSON
886+ json:
887+ type: string
888+ contentType:
889+ type: string
890+ RawJsonResponseBody:
891+ type: object
892+ description: "json response body"
893+ additionalProperties: true
894+ StringResponseBody:
895+ type: object
896+ description: "string response body"
897+ additionalProperties: false
898+ properties:
899+ not:
900+ type: boolean
901+ type:
902+ enum:
903+ - STRING
904+ string:
905+ type: string
906+ contentType:
907+ type: string
908+ RawStringResponseBody:
909+ type: string
910+ description: "string response body"
911+ XmlResponseBody:
912+ type: object
913+ description: "xml response body"
914+ additionalProperties: false
915+ properties:
916+ not:
917+ type: boolean
918+ type:
919+ enum:
920+ - XML
921+ xml:
922+ type: string
923+ contentType:
924+ type: string
865925 BodyWithContentType:
866926 description: "response body"
867927 anyOf:
868− - type: object
869− description: "binary response body"
870− additionalProperties: false
871− properties:
872− not:
873− type: boolean
874− type:
875− enum:
876− - BINARY
877− base64Bytes:
878− type: string
879− contentType:
880− type: string
881− - type: object
882− description: "json response body"
883− additionalProperties: false
884− properties:
885− not:
886− type: boolean
887− type:
888− enum:
889− - JSON
890− json:
891− type: string
892− contentType:
893− type: string
894− - type: object
895− description: "json response body"
896− additionalProperties: true
897− - type: object
898− description: "string response body"
899− additionalProperties: false
900− properties:
901− not:
902− type: boolean
903− type:
904− enum:
905− - STRING
906− string:
907− type: string
908− contentType:
909− type: string
910− - type: string
911− description: "string response body"
912− - type: object
913− description: "xml response body"
914− additionalProperties: false
915− properties:
916− not:
917− type: boolean
918− type:
919− enum:
920− - XML
921− xml:
922− type: string
923− contentType:
924− type: string
928+ - $ref: "#/components/schemas/BinaryBodyResponse"
929+ - $ref: "#/components/schemas/JsonResponseBody"
930+ - $ref: "#/components/schemas/RawJsonResponseBody"
931+ - $ref: "#/components/schemas/StringResponseBody"
932+ - $ref: "#/components/schemas/RawStringResponseBody"
933+ - $ref: "#/components/schemas/XmlResponseBody"
925934 Delay:
926935 description: "response delay"
927936 type: object
@@ -963,11 +972,6 @@ components:
963972 $ref: "#/components/schemas/VerificationTimes"
964973 maximumNumberOfRequestToReturnInVerificationFailure:
965974 type: integer
966− oneOf:
967− - required:
968− - expectationId
969− - required:
970− - httpRequest
971975 VerificationTimes:
972976 description: "number of request to verify"
973977 type: object
@@ -993,11 +997,6 @@ components:
993997 $ref: "#/components/schemas/RequestDefinition"
994998 maximumNumberOfRequestToReturnInVerificationFailure:
995999 type: integer
996− oneOf:
997− - required:
998− - expectationIds
999− - required:
1000− - httpRequests
10011000 Ports:
10021001 description: "list of ports"
10031002 type: object
@@ -1007,14 +1006,3 @@ components:
10071006 items:
10081007 type: number
10091008 type: array
1010− HttpRequestAndHttpResponse:
1011− description: "request and response"
1012− type: object
1013− additionalProperties: false
1014− properties:
1015− httpRequest:
1016− $ref: "#/components/schemas/HttpRequest"
1017− httpResponse:
1018− $ref: "#/components/schemas/HttpResponse"
1019− timestamp:
1020− type: string
ghc-9.0.2.yamlnew file+8
@@ -0,0 +1,8 @@
1+resolver: lts-19.33
2+
3+nix:
4+ packages:
5+ - zlib
6+
7+packages:
8+ - .
ghc-9.0.2.yaml.locknew file+12
@@ -0,0 +1,12 @@
1+# This file was autogenerated by Stack.
2+# You should not edit this file by hand.
3+# For more information, please see the documentation at:
4+# https://docs.haskellstack.org/en/stable/lock_files
5+
6+packages: []
7+snapshots:
8+- completed:
9+ sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4
10+ size: 619204
11+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml
12+ original: lts-19.33
ghc-9.2.5.yamlnew file+8
@@ -0,0 +1,8 @@
1+resolver: lts-20.8
2+
3+nix:
4+ packages:
5+ - zlib
6+
7+packages:
8+ - .
ghc-9.2.5.yaml.locknew file+12
@@ -0,0 +1,12 @@
1+# This file was autogenerated by Stack.
2+# You should not edit this file by hand.
3+# For more information, please see the documentation at:
4+# https://docs.haskellstack.org/en/stable/lock_files
5+
6+packages: []
7+snapshots:
8+- completed:
9+ sha256: bfafe5735ccb74527d754b1f9999ded72d7c3a6c3a88529449661431ccfbd6cc
10+ size: 649327
11+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/8.yaml
12+ original: lts-20.8
mock-server-client.cabal+3
@@ -47,6 +47,7 @@ library
4747 MockServer.Types.OpenAPIExpectations
4848 MockServer.Types.ParameterBodyMatcher
4949 MockServer.Types.Ports
50+ MockServer.Types.Protocol
5051 MockServer.Types.RegexBodyMatcher
5152 MockServer.Types.RequestDefinition
5253 MockServer.Types.SocketAddress
@@ -76,6 +77,7 @@ library
7677 , http-types
7778 , bytestring
7879 , aeson
80+ , openapi3
7981 , unordered-containers
8082 , vector
8183 , scientific
@@ -83,3 +85,4 @@ library
8385 , mtl
8486 , transformers
8587 default-language: Haskell2010
88+ default-extensions: DeriveGeneric
src/MockServer.hs+2
@@ -42,6 +42,7 @@ module MockServer (
4242 module MockServer.Types.OpenAPIExpectations,
4343 module MockServer.Types.ParameterBodyMatcher,
4444 module MockServer.Types.Ports,
45+ module MockServer.Types.Protocol,
4546 module MockServer.Types.RegexBodyMatcher,
4647 module MockServer.Types.RequestDefinition,
4748 module MockServer.Types.SocketAddress,
@@ -102,6 +103,7 @@ import MockServer.Types.OpenAPIExpectation
102103import MockServer.Types.OpenAPIExpectations
103104import MockServer.Types.ParameterBodyMatcher
104105import MockServer.Types.Ports
106+import MockServer.Types.Protocol
105107import MockServer.Types.RegexBodyMatcher
106108import MockServer.Types.RequestDefinition
107109import MockServer.Types.SocketAddress
src/MockServer/Common.hs+23−5
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE FlexibleInstances #-}
23{-# LANGUAGE GeneralizedNewtypeDeriving #-}
34{-# LANGUAGE LambdaCase #-}
@@ -33,12 +34,18 @@ where
3334import qualified Control.Monad.IO.Class as MIO
3435import qualified Control.Monad.Reader as MR
3536import qualified Control.Monad.Trans.Class as MT
37+#if MIN_VERSION_aeson(2,0,0)
38+import qualified Data.Aeson.KeyMap as KeyMap
39+import qualified Data.Aeson.Key as Key
40+import Data.Bifunctor
41+#else
42+import qualified Data.HashMap.Strict as HashMap
43+#endif
3644import qualified Data.Aeson as Aeson
3745import qualified Data.Aeson.Encoding as Encoding
3846import qualified Data.Bifunctor as BF
3947import qualified Data.ByteString.Char8 as B8
4048import qualified Data.ByteString.Lazy.Char8 as LB8
41−import qualified Data.HashMap.Strict as HMap
4249import qualified Data.Maybe as Maybe
4350import qualified Data.Scientific as Scientific
4451import Data.Text (Text)
@@ -50,6 +57,15 @@ import qualified Network.HTTP.Client as HC
5057import qualified Network.HTTP.Simple as HS
5158import qualified Network.HTTP.Types as HT
5259
60+
61+#if MIN_VERSION_aeson(2,0,0)
62+toList' :: Aeson.Object -> [(Text, Aeson.Value)]
63+toList' = fmap (first Key.toText) . KeyMap.toList
64+#else
65+toList' :: Aeson.Object -> [(Text, Aeson.Value)]
66+toList' = HashMap.toList
67+#endif
68+
5369-- | Abstracts the usage of 'Network.HTTP.Simple.httpBS' away,
5470-- so that it can be used for testing
5571class Monad m => MonadHTTP m where
@@ -285,8 +301,10 @@ jsonToFormDataFlat _ Aeson.Null = []
285301jsonToFormDataFlat name (Aeson.Number a) = [(name, encodeStrict a)]
286302jsonToFormDataFlat name (Aeson.String a) = [(name, textToByte a)]
287303jsonToFormDataFlat name (Aeson.Bool a) = [(name, encodeStrict a)]
288−jsonToFormDataFlat _ (Aeson.Object object) = HMap.toList object >>= uncurry jsonToFormDataFlat . BF.first Just
289−jsonToFormDataFlat name (Aeson.Array vector) = Vector.toList vector >>= jsonToFormDataFlat name
304+jsonToFormDataFlat _ (Aeson.Object object) =
305+ toList' object >>= uncurry jsonToFormDataFlat . BF.first Just
306+jsonToFormDataFlat name (Aeson.Array vector) =
307+ Vector.toList vector >>= jsonToFormDataFlat name
290308
291309-- | creates form data bytestring array
292310createFormData :: (Aeson.ToJSON a) => a -> [(B8.ByteString, B8.ByteString)]
@@ -320,9 +338,9 @@ jsonToFormDataPrefixed prefix (Aeson.Bool False) = [(prefix, "false")]
320338jsonToFormDataPrefixed _ Aeson.Null = []
321339jsonToFormDataPrefixed prefix (Aeson.String a) = [(prefix, a)]
322340jsonToFormDataPrefixed "" (Aeson.Object object) =
323− HMap.toList object >>= uncurry jsonToFormDataPrefixed
341+ toList' object >>= uncurry jsonToFormDataPrefixed
324342jsonToFormDataPrefixed prefix (Aeson.Object object) =
325− HMap.toList object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y)
343+ toList' object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y)
326344jsonToFormDataPrefixed prefix (Aeson.Array vector) =
327345 Vector.toList vector >>= jsonToFormDataPrefixed (prefix <> "[]")
328346
src/MockServer/Operations/Put_mockserver_retrieve.hs+2−2
@@ -62,7 +62,7 @@ put_mockserver_retrieve parameters
6262data Put_mockserver_retrieveParameters = Put_mockserver_retrieveParameters {
6363 -- | queryFormat: Represents the parameter named \'format\'
6464 --
65− -- changes response format, default if not specificed is \"json\", supported values are \"java\", \"json\", \"log_entries\"
65+ -- changes response format, default if not specified is \"json\", supported values are \"java\", \"json\", \"log_entries\"
6666 put_mockserver_retrieveParametersQueryFormat :: (GHC.Maybe.Maybe Put_mockserver_retrieveParametersQueryFormat)
6767 -- | queryType: Represents the parameter named \'type\'
6868 --
@@ -83,7 +83,7 @@ mkPut_mockserver_retrieveParameters = Put_mockserver_retrieveParameters{put_mock
8383--
8484-- Represents the parameter named \'format\'
8585--
86−-- changes response format, default if not specificed is \"json\", supported values are \"java\", \"json\", \"log_entries\"
86+-- changes response format, default if not specified is \"json\", supported values are \"java\", \"json\", \"log_entries\"
8787data Put_mockserver_retrieveParametersQueryFormat =
8888 Put_mockserver_retrieveParametersQueryFormatOther Data.Aeson.Types.Internal.Value -- ^ This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
8989 | Put_mockserver_retrieveParametersQueryFormatTyped Data.Text.Internal.Text -- ^ This constructor can be used to send values to the server which are not present in the specification yet.
src/MockServer/Types.hs+2
@@ -31,6 +31,7 @@ module MockServer.Types (
3131 module MockServer.Types.OpenAPIExpectations,
3232 module MockServer.Types.ParameterBodyMatcher,
3333 module MockServer.Types.Ports,
34+ module MockServer.Types.Protocol,
3435 module MockServer.Types.RegexBodyMatcher,
3536 module MockServer.Types.RequestDefinition,
3637 module MockServer.Types.SocketAddress,
@@ -77,6 +78,7 @@ import MockServer.Types.OpenAPIExpectation
7778import MockServer.Types.OpenAPIExpectations
7879import MockServer.Types.ParameterBodyMatcher
7980import MockServer.Types.Ports
81+import MockServer.Types.Protocol
8082import MockServer.Types.RegexBodyMatcher
8183import MockServer.Types.RequestDefinition
8284import MockServer.Types.SocketAddress
src/MockServer/Types/HttpRequest.hs+7−3
@@ -35,6 +35,7 @@ import MockServer.TypeAlias
3535import {-# SOURCE #-} MockServer.Types.Body
3636import {-# SOURCE #-} MockServer.Types.KeyToMultiValue
3737import {-# SOURCE #-} MockServer.Types.KeyToValue
38+import {-# SOURCE #-} MockServer.Types.Protocol
3839import {-# SOURCE #-} MockServer.Types.SocketAddress
3940import {-# SOURCE #-} MockServer.Types.StringOrJsonSchema
4041
@@ -56,6 +57,8 @@ data HttpRequest = HttpRequest {
5657 , httpRequestPath :: (GHC.Maybe.Maybe StringOrJsonSchema)
5758 -- | pathParameters
5859 , httpRequestPathParameters :: (GHC.Maybe.Maybe KeyToMultiValue)
60+ -- | protocol: protocol matcher
61+ , httpRequestProtocol :: (GHC.Maybe.Maybe Protocol)
5962 -- | queryStringParameters
6063 , httpRequestQueryStringParameters :: (GHC.Maybe.Maybe KeyToMultiValue)
6164 -- | secure
@@ -65,10 +68,10 @@ data HttpRequest = HttpRequest {
6568 } deriving (GHC.Show.Show
6669 , GHC.Classes.Eq)
6770instance Data.Aeson.Types.ToJSON.ToJSON HttpRequest
68− where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("body" Data.Aeson.Types.ToJSON..=)) (httpRequestBody obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("cookies" Data.Aeson.Types.ToJSON..=)) (httpRequestCookies obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("headers" Data.Aeson.Types.ToJSON..=)) (httpRequestHeaders obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("keepAlive" Data.Aeson.Types.ToJSON..=)) (httpRequestKeepAlive obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("method" Data.Aeson.Types.ToJSON..=)) (httpRequestMethod obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("path" Data.Aeson.Types.ToJSON..=)) (httpRequestPath obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("pathParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestPathParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryStringParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestQueryStringParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("secure" Data.Aeson.Types.ToJSON..=)) (httpRequestSecure obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("socketAddress" Data.Aeson.Types.ToJSON..=)) (httpRequestSocketAddress obj) : GHC.Base.mempty))
69− toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("body" Data.Aeson.Types.ToJSON..=)) (httpRequestBody obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("cookies" Data.Aeson.Types.ToJSON..=)) (httpRequestCookies obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("headers" Data.Aeson.Types.ToJSON..=)) (httpRequestHeaders obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("keepAlive" Data.Aeson.Types.ToJSON..=)) (httpRequestKeepAlive obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("method" Data.Aeson.Types.ToJSON..=)) (httpRequestMethod obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("path" Data.Aeson.Types.ToJSON..=)) (httpRequestPath obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("pathParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestPathParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryStringParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestQueryStringParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("secure" Data.Aeson.Types.ToJSON..=)) (httpRequestSecure obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("socketAddress" Data.Aeson.Types.ToJSON..=)) (httpRequestSocketAddress obj) : GHC.Base.mempty)))
71+ where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("body" Data.Aeson.Types.ToJSON..=)) (httpRequestBody obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("cookies" Data.Aeson.Types.ToJSON..=)) (httpRequestCookies obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("headers" Data.Aeson.Types.ToJSON..=)) (httpRequestHeaders obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("keepAlive" Data.Aeson.Types.ToJSON..=)) (httpRequestKeepAlive obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("method" Data.Aeson.Types.ToJSON..=)) (httpRequestMethod obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("path" Data.Aeson.Types.ToJSON..=)) (httpRequestPath obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("pathParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestPathParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("protocol" Data.Aeson.Types.ToJSON..=)) (httpRequestProtocol obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryStringParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestQueryStringParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("secure" Data.Aeson.Types.ToJSON..=)) (httpRequestSecure obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("socketAddress" Data.Aeson.Types.ToJSON..=)) (httpRequestSocketAddress obj) : GHC.Base.mempty))
72+ toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("body" Data.Aeson.Types.ToJSON..=)) (httpRequestBody obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("cookies" Data.Aeson.Types.ToJSON..=)) (httpRequestCookies obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("headers" Data.Aeson.Types.ToJSON..=)) (httpRequestHeaders obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("keepAlive" Data.Aeson.Types.ToJSON..=)) (httpRequestKeepAlive obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("method" Data.Aeson.Types.ToJSON..=)) (httpRequestMethod obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("path" Data.Aeson.Types.ToJSON..=)) (httpRequestPath obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("pathParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestPathParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("protocol" Data.Aeson.Types.ToJSON..=)) (httpRequestProtocol obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryStringParameters" Data.Aeson.Types.ToJSON..=)) (httpRequestQueryStringParameters obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("secure" Data.Aeson.Types.ToJSON..=)) (httpRequestSecure obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("socketAddress" Data.Aeson.Types.ToJSON..=)) (httpRequestSocketAddress obj) : GHC.Base.mempty)))
7073instance Data.Aeson.Types.FromJSON.FromJSON HttpRequest
71− where parseJSON = Data.Aeson.Types.FromJSON.withObject "HttpRequest" (\obj -> (((((((((GHC.Base.pure HttpRequest GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "body")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "cookies")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "headers")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "keepAlive")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "method")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "path")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "pathParameters")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "queryStringParameters")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "secure")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "socketAddress"))
74+ where parseJSON = Data.Aeson.Types.FromJSON.withObject "HttpRequest" (\obj -> ((((((((((GHC.Base.pure HttpRequest GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "body")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "cookies")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "headers")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "keepAlive")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "method")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "path")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "pathParameters")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "protocol")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "queryStringParameters")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "secure")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "socketAddress"))
7275-- | Create a new 'HttpRequest' with all required fields.
7376mkHttpRequest :: HttpRequest
7477mkHttpRequest = HttpRequest{httpRequestBody = GHC.Maybe.Nothing,
@@ -78,6 +81,7 @@ mkHttpRequest = HttpRequest{httpRequestBody = GHC.Maybe.Nothing,
7881 httpRequestMethod = GHC.Maybe.Nothing,
7982 httpRequestPath = GHC.Maybe.Nothing,
8083 httpRequestPathParameters = GHC.Maybe.Nothing,
84+ httpRequestProtocol = GHC.Maybe.Nothing,
8185 httpRequestQueryStringParameters = GHC.Maybe.Nothing,
8286 httpRequestSecure = GHC.Maybe.Nothing,
8387 httpRequestSocketAddress = GHC.Maybe.Nothing}
src/MockServer/Types/JsonSchemaBodyMatcher.hs+6−6
@@ -6,20 +6,19 @@
66-- | Contains the types generated from the schema JsonSchemaBodyMatcher
77module MockServer.Types.JsonSchemaBodyMatcher where
88
9−import qualified Prelude as GHC.Integer.Type
10−import qualified Prelude as GHC.Maybe
119import qualified Control.Monad.Fail
1210import qualified Data.Aeson
1311import qualified Data.Aeson as Data.Aeson.Encoding.Internal
1412import qualified Data.Aeson as Data.Aeson.Types
1513import qualified Data.Aeson as Data.Aeson.Types.FromJSON
16−import qualified Data.Aeson as Data.Aeson.Types.ToJSON
1714import qualified Data.Aeson as Data.Aeson.Types.Internal
15+import qualified Data.Aeson as Data.Aeson.Types.ToJSON
1816import qualified Data.ByteString.Char8
1917import qualified Data.ByteString.Char8 as Data.ByteString.Internal
2018import qualified Data.Foldable
2119import qualified Data.Functor
2220import qualified Data.Maybe
21+import Data.OpenApi.Internal (Schema)
2322import qualified Data.Scientific
2423import qualified Data.Text
2524import qualified Data.Text.Internal
@@ -32,14 +31,15 @@ import qualified GHC.Show
3231import qualified GHC.Types
3332import qualified MockServer.Common
3433import MockServer.TypeAlias
35−import {-# SOURCE #-} MockServer.Types.Http__JsonSchema_OrgDraft_04Schema
34+import qualified Prelude as GHC.Integer.Type
35+import qualified Prelude as GHC.Maybe
3636
3737-- | Defines the object schema located at @components.schemas.JsonSchemaBodyMatcher@ in the specification.
38−--
38+--
3939-- json schema body matcher
4040data JsonSchemaBodyMatcher = JsonSchemaBodyMatcher {
4141 -- | jsonSchema
42− jsonSchemaBodyMatcherJsonSchema :: (GHC.Maybe.Maybe Http___json_schema'org_draft_04_schema)
42+ jsonSchemaBodyMatcherJsonSchema :: (GHC.Maybe.Maybe Schema)
4343 -- | not
4444 , jsonSchemaBodyMatcherNot :: (GHC.Maybe.Maybe GHC.Types.Bool)
4545 -- | type
src/MockServer/Types/Protocol.hsnew file+53
@@ -0,0 +1,53 @@
1+-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator.
2+
3+{-# LANGUAGE OverloadedStrings #-}
4+{-# LANGUAGE MultiWayIf #-}
5+
6+-- | Contains the types generated from the schema Protocol
7+module MockServer.Types.Protocol where
8+
9+import qualified Prelude as GHC.Integer.Type
10+import qualified Prelude as GHC.Maybe
11+import qualified Control.Monad.Fail
12+import qualified Data.Aeson
13+import qualified Data.Aeson as Data.Aeson.Encoding.Internal
14+import qualified Data.Aeson as Data.Aeson.Types
15+import qualified Data.Aeson as Data.Aeson.Types.FromJSON
16+import qualified Data.Aeson as Data.Aeson.Types.ToJSON
17+import qualified Data.Aeson as Data.Aeson.Types.Internal
18+import qualified Data.ByteString.Char8
19+import qualified Data.ByteString.Char8 as Data.ByteString.Internal
20+import qualified Data.Foldable
21+import qualified Data.Functor
22+import qualified Data.Maybe
23+import qualified Data.Scientific
24+import qualified Data.Text
25+import qualified Data.Text.Internal
26+import qualified Data.Time.Calendar as Data.Time.Calendar.Days
27+import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
28+import qualified GHC.Base
29+import qualified GHC.Classes
30+import qualified GHC.Int
31+import qualified GHC.Show
32+import qualified GHC.Types
33+import qualified MockServer.Common
34+import MockServer.TypeAlias
35+
36+-- | Defines the enum schema located at @components.schemas.Protocol@ in the specification.
37+--
38+-- protocol matcher
39+data Protocol =
40+ ProtocolOther Data.Aeson.Types.Internal.Value -- ^ This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
41+ | ProtocolTyped Data.Aeson.Types.Internal.Object -- ^ This constructor can be used to send values to the server which are not present in the specification yet.
42+ | ProtocolEnumHTTP_1_1 -- ^ Represents the JSON value @"HTTP_1_1"@
43+ | ProtocolEnumHTTP_2 -- ^ Represents the JSON value @"HTTP_2"@
44+ deriving (GHC.Show.Show, GHC.Classes.Eq)
45+instance Data.Aeson.Types.ToJSON.ToJSON Protocol
46+ where toJSON (ProtocolOther val) = val
47+ toJSON (ProtocolTyped val) = Data.Aeson.Types.ToJSON.toJSON val
48+ toJSON (ProtocolEnumHTTP_1_1) = "HTTP_1_1"
49+ toJSON (ProtocolEnumHTTP_2) = "HTTP_2"
50+instance Data.Aeson.Types.FromJSON.FromJSON Protocol
51+ where parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "HTTP_1_1" -> ProtocolEnumHTTP_1_1
52+ | val GHC.Classes.== "HTTP_2" -> ProtocolEnumHTTP_2
53+ | GHC.Base.otherwise -> ProtocolOther val)
src/MockServer/Types/Protocol.hs-bootnew file+9
@@ -0,0 +1,9 @@
1+module MockServer.Types.Protocol where
2+import Data.Aeson
3+import qualified Data.Aeson as Data.Aeson.Types.Internal
4+import qualified MockServer.Common
5+data Protocol
6+instance Show Protocol
7+instance Eq Protocol
8+instance FromJSON Protocol
9+instance ToJSON Protocol
src/MockServer/Types/StringOrJsonSchema.hs+7−7
@@ -6,20 +6,19 @@
66-- | Contains the types generated from the schema StringOrJsonSchema
77module MockServer.Types.StringOrJsonSchema where
88
9−import qualified Prelude as GHC.Integer.Type
10−import qualified Prelude as GHC.Maybe
119import qualified Control.Monad.Fail
1210import qualified Data.Aeson
1311import qualified Data.Aeson as Data.Aeson.Encoding.Internal
1412import qualified Data.Aeson as Data.Aeson.Types
1513import qualified Data.Aeson as Data.Aeson.Types.FromJSON
16−import qualified Data.Aeson as Data.Aeson.Types.ToJSON
1714import qualified Data.Aeson as Data.Aeson.Types.Internal
15+import qualified Data.Aeson as Data.Aeson.Types.ToJSON
1816import qualified Data.ByteString.Char8
1917import qualified Data.ByteString.Char8 as Data.ByteString.Internal
2018import qualified Data.Foldable
2119import qualified Data.Functor
2220import qualified Data.Maybe
21+import Data.OpenApi.Internal (Schema)
2322import qualified Data.Scientific
2423import qualified Data.Text
2524import qualified Data.Text.Internal
@@ -32,11 +31,12 @@ import qualified GHC.Show
3231import qualified GHC.Types
3332import qualified MockServer.Common
3433import MockServer.TypeAlias
35−import {-# SOURCE #-} MockServer.Types.Http__JsonSchema_OrgDraft_04Schema
34+import qualified Prelude as GHC.Integer.Type
35+import qualified Prelude as GHC.Maybe
3636
3737-- | Defines the object schema located at @components.schemas.StringOrJsonSchema.oneOf@ in the specification.
38−--
39−--
38+--
39+--
4040data StringOrJsonSchemaOneOf2 = StringOrJsonSchemaOneOf2 {
4141 -- | not
4242 stringOrJsonSchemaOneOf2Not :: (GHC.Maybe.Maybe GHC.Types.Bool)
@@ -45,7 +45,7 @@ data StringOrJsonSchemaOneOf2 = StringOrJsonSchemaOneOf2 {
4545 -- | parameterStyle
4646 , stringOrJsonSchemaOneOf2ParameterStyle :: (GHC.Maybe.Maybe StringOrJsonSchemaOneOf2ParameterStyle)
4747 -- | schema
48− , stringOrJsonSchemaOneOf2Schema :: (GHC.Maybe.Maybe Http___json_schema'org_draft_04_schema)
48+ , stringOrJsonSchemaOneOf2Schema :: (GHC.Maybe.Maybe Schema)
4949 -- | value
5050 , stringOrJsonSchemaOneOf2Value :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
5151 } deriving (GHC.Show.Show