git.iko.soy/typeable/mock-server-client
on master help sign in
.github/workflows/haskell-ci.ymlnew file+25
since splitsnapshots
unifiedsplit
@@ -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
2
2
3The package is the client library for the [mock server](https://www.mock-server.com/). The source code is
3The package is the client library for the [mock server](https://www.mock-server.com/). The source code is
4generated by the [openapi3-code-generator](https://hackage.haskell.org/package/openapi3-code-generator), specifically its patched version.
4generated by the [openapi3-code-generator](https://hackage.haskell.org/package/openapi3-code-generator), specifically its patched version.
5
5
6−## How to regenerate
6+## Usage
7
7
8−```
8+``` haskell
9−cd codegen && ./regen.sh
9+module Main
10−```
11
10
12−It requires the `nix` to be installed in your system because it uses the
11+import MockServer as Mock
13−`openapi3-code-generator` built by the `nix`.
12+import Network.HTTP.Client
14
13
15−After regeneration you will see some `.hs` files changed. This is because some
14+conf :: Mock.Configuration
16−parts of the libary are modified by hand to make the more usable.
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
17
40
18## Files
41## Files
19
42
20### The `codegen` dir
43### The `codegen` dir
21
44
22* `regen.sh` is the simple script to regenerate the whole package.
45* `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
46+* `shell.nix` a shell in which the `regen.sh` calls the `openapi3-code-generator` to regenerate the code
24−* `mock-server-openapi-5.13.x-swagger.yaml` not the original file as you might
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
25− think. The thing is that the `openapi3-code-generator` does not support all
48+ think. The thing is that the `openapi3-code-generator` does not support all the features of the
26− the features of the OpenAPI3 standard correctly, so it is
49+ OpenAPI3 standard correctly, so it is hand-postprocessed. It was originally downloaded from
27− hand-postprocessed. It was originally downloaded from [here](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.13.x) and fixed.
50+ [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
51+
29− generted code was not very pleasant, so it was fixed too.
52+### Other
30
53
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+
31−### What will happen if you just call the `regen.sh`?
57+## What will happen if you just call the `regen.sh`?
32
58
33It will build the `openapi3-code-generator` in `nix` and regenerate the whole
59It will build the `openapi3-code-generator` in `nix` and regenerate the whole
34Haskell source code. You will see that the code was changed, because as
60Haskell source code. You will see that the code was changed, because as
35mentioned earlier the original code was slightly modified, so watch your commits.
61mentioned earlier the original code was slightly modified, so watch your commits.
36
62
37−## How the to update the package to the new version of the `mock-server`?
63+## How to update the package to the new version of the `mock-server` spec?
38−
64+
39−* Commit all changes in git
65+* Commit or discard all changes
40−* Run the `regen.sh` and regenerate the whole package
66+* `git checkout update-openapi-spec`
41−* Run `git diff -p > src.patch` and save the manual changes made to the source code
67+* Replace the `codegen/mock-server-openapi.yaml` with a newer version
42−* Download the [original spec](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi/5.13.x) in place of our patched spec file
68+* `git commit -m "updated mock-server-openapi.yaml to version $NEWVERSION"`
43−* Run the `git diff -- codegen/mock-server-openapi-5.13.x-swagger.yaml -p > spec.patch`
69+* `git checkout -b "update-$NEWVERSION" master`
44−* Download the [new spec](https://app.swaggerhub.com/apis/jamesdbloom/mock-server-openapi) and put it in place of the old one
70+* `git merge update-openapi-spec`
45−* Try to `git apply spec.patch` to the newer version of the spec to apply manual
71+* Resolve conflicts if any
46− changes to the new spec. If somethig goes wrong use AI to fix it for you, heh.
72+* `./codegen/regen.sh`
47−* Fix the `regen.sh` and rename the `mock-server-openapi-5.13.x-swagger.yaml` to
73+* `git symbolic-ref HEAD refs/heads/update-generated-code && git reset`
48− the newer version.
74+ switching to the branch `update-generated-code` without checking out the working-tree
49−* `git commit -m 'dangerous action'`
75+* `git commit -m "update the generted code for version $NEWVERSION"`
50−* Run the `regen.sh` so you will hopefuly have a new version of the client code
76+* `git checkout "update-$NEWVERSION"`
51− generated.
77+* `git merge update-generated-code`
52−* `git apply src.patch` to apply manual patches to the new version.
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:
4 - url: 'https://localhost:1080/'
4 - url: 'https://localhost:1080/'
5info:
5info:
6 title: MockServer API
6 title: MockServer API
7− version: 5.13.x
7+ version: 5.15.x
8 description: >-
8 description: >-
9 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).
9 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).
10
10
@@ -18,7 +18,7 @@ info:
18 name: Apache 2.0
18 name: Apache 2.0
19tags:
19tags:
20 - name: expectation
20 - 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)
22 - name: verify
22 - name: verify
23 description: Verify requests (both MockServer & MockServer Proxy)
23 description: Verify requests (both MockServer & MockServer Proxy)
24 - name: control
24 - name: control
@@ -36,7 +36,7 @@ paths:
36 content:
36 content:
37 application/json:
37 application/json:
38 schema:
38 schema:
39− description: "list of upserted expectations"
39+ title: list of upserted expectations
40 type: array
40 type: array
41 additionalProperties: false
41 additionalProperties: false
42 items:
42 items:
@@ -63,7 +63,7 @@ paths:
63 content:
63 content:
64 application/json:
64 application/json:
65 schema:
65 schema:
66− description: "list of upserted expectations"
66+ title: list of upserted expectations
67 type: array
67 type: array
68 additionalProperties: false
68 additionalProperties: false
69 items:
69 items:
@@ -89,15 +89,6 @@ paths:
89 description: expectations and recorded requests cleared
89 description: expectations and recorded requests cleared
90 '400':
90 '400':
91 description: incorrect request format
91 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"
101 requestBody:
92 requestBody:
102 content:
93 content:
103 application/json:
94 application/json:
@@ -105,7 +96,7 @@ paths:
105 oneOf:
96 oneOf:
106 - $ref: "#/components/schemas/RequestDefinition"
97 - $ref: "#/components/schemas/RequestDefinition"
107 - $ref: "#/components/schemas/ExpectationId"
98 - $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
109 /mockserver/reset:
100 /mockserver/reset:
110 put:
101 put:
111 tags:
102 tags:
@@ -125,14 +116,12 @@ paths:
125 schema:
116 schema:
126 type: string
117 type: string
127 enum: [ "java", "json", "log_entries" ]
118 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"
130 - in: query
120 - in: query
131 name: type
121 name: type
132 schema:
122 schema:
133 type: string
123 type: string
134 enum: [ "logs", "requests", "request_responses", "recorded_expectations", "active_expectations" ]
124 enum: [ "logs", "requests", "request_responses", "recorded_expectations", "active_expectations" ]
135− required: false
136 description: specifies the type of object that is retrieve, default if not specified is "requests", supported values are "logs", "requests", "recorded_expectations", "active_expectations"
125 description: specifies the type of object that is retrieve, default if not specified is "requests", supported values are "logs", "requests", "recorded_expectations", "active_expectations"
137 responses:
126 responses:
138 '200':
127 '200':
@@ -148,11 +137,7 @@ paths:
148 - type: array
137 - type: array
149 additionalProperties: false
138 additionalProperties: false
150 items:
139 items:
151− $ref: "#/components/schemas/HttpRequest"
140+ $ref: "#/components/schemas/HttpResponse"
152− - type: array
153− additionalProperties: false
154− items:
155− $ref: "#/components/schemas/HttpRequestAndHttpResponse"
156 application/java:
141 application/java:
157 schema:
142 schema:
158 type: string
143 type: string
@@ -272,7 +257,7 @@ paths:
272components:
257components:
273 schemas:
258 schemas:
274 Expectations:
259 Expectations:
275− description: "list of expectations"
260+ title: "list of expectations"
276 oneOf:
261 oneOf:
277 - $ref: "#/components/schemas/Expectation"
262 - $ref: "#/components/schemas/Expectation"
278 - type: array
263 - type: array
@@ -280,7 +265,7 @@ components:
280 items:
265 items:
281 $ref: "#/components/schemas/Expectation"
266 $ref: "#/components/schemas/Expectation"
282 Expectation:
267 Expectation:
283− description: "expectation"
268+ title: "expectation"
284 type: object
269 type: object
285 additionalProperties: false
270 additionalProperties: false
286 properties:
271 properties:
@@ -290,6 +275,8 @@ components:
290 type: integer
275 type: integer
291 httpRequest:
276 httpRequest:
292 $ref: "#/components/schemas/RequestDefinition"
277 $ref: "#/components/schemas/RequestDefinition"
278+ openAPIDefinition:
279+ $ref: "#/components/schemas/OpenAPIDefinition"
293 httpResponse:
280 httpResponse:
294 $ref: "#/components/schemas/HttpResponse"
281 $ref: "#/components/schemas/HttpResponse"
295 httpResponseTemplate:
282 httpResponseTemplate:
@@ -314,29 +301,8 @@ components:
314 $ref: "#/components/schemas/Times"
301 $ref: "#/components/schemas/Times"
315 timeToLive:
302 timeToLive:
316 $ref: "#/components/schemas/TimeToLive"
303 $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
338 ExpectationId:
304 ExpectationId:
339− description: "pointer to existing expectation"
305+ title: "pointer to existing expectation"
340 type: object
306 type: object
341 additionalProperties: false
307 additionalProperties: false
342 properties:
308 properties:
@@ -345,7 +311,7 @@ components:
345 required:
311 required:
346 - id
312 - id
347 OpenAPIExpectations:
313 OpenAPIExpectations:
348− description: "list of open api expectations"
314+ title: "list of open api expectations"
349 oneOf:
315 oneOf:
350 - $ref: "#/components/schemas/OpenAPIExpectation"
316 - $ref: "#/components/schemas/OpenAPIExpectation"
351 - type: array
317 - type: array
@@ -353,7 +319,7 @@ components:
353 items:
319 items:
354 $ref: "#/components/schemas/OpenAPIExpectation"
320 $ref: "#/components/schemas/OpenAPIExpectation"
355 OpenAPIExpectation:
321 OpenAPIExpectation:
356− description: "open api or swagger expectation"
322+ title: "open api or swagger expectation"
357 type: object
323 type: object
358 additionalProperties: false
324 additionalProperties: false
359 properties:
325 properties:
@@ -368,12 +334,12 @@ components:
368 required:
334 required:
369 - specUrlOrPayload
335 - specUrlOrPayload
370 RequestDefinition:
336 RequestDefinition:
371− description: "request definition"
337+ title: "request definition"
372 oneOf:
338 oneOf:
373 - $ref: "#/components/schemas/HttpRequest"
339 - $ref: "#/components/schemas/HttpRequest"
374 - $ref: "#/components/schemas/OpenAPIDefinition"
340 - $ref: "#/components/schemas/OpenAPIDefinition"
375 HttpRequest:
341 HttpRequest:
376− description: "request properties matcher"
342+ title: "request properties matcher"
377 type: object
343 type: object
378 additionalProperties: false
344 additionalProperties: false
379 properties:
345 properties:
@@ -397,8 +363,10 @@ components:
397 $ref: "#/components/schemas/KeyToValue"
363 $ref: "#/components/schemas/KeyToValue"
398 socketAddress:
364 socketAddress:
399 $ref: "#/components/schemas/SocketAddress"
365 $ref: "#/components/schemas/SocketAddress"
366+ protocol:
367+ $ref: "#/components/schemas/Protocol"
400 OpenAPIDefinition:
368 OpenAPIDefinition:
401− description: "open api or swagger request matcher"
369+ title: "open api or swagger request matcher"
402 type: object
370 type: object
403 additionalProperties: false
371 additionalProperties: false
404 properties:
372 properties:
@@ -407,7 +375,7 @@ components:
407 operationId:
375 operationId:
408 type: string
376 type: string
409 HttpResponse:
377 HttpResponse:
410− description: "response to return"
378+ title: "response to return"
411 type: object
379 type: object
412 additionalProperties: false
380 additionalProperties: false
413 properties:
381 properties:
@@ -426,7 +394,7 @@ components:
426 reasonPhrase:
394 reasonPhrase:
427 type: string
395 type: string
428 HttpTemplate:
396 HttpTemplate:
429− description: "template to generate response / request"
397+ title: "template to generate response / request"
430 type: object
398 type: object
431 additionalProperties: false
399 additionalProperties: false
432 properties:
400 properties:
@@ -440,7 +408,7 @@ components:
440 template:
408 template:
441 type: string
409 type: string
442 HttpForward:
410 HttpForward:
443− description: "host and port to forward to"
411+ title: host and port to forward to
444 type: object
412 type: object
445 additionalProperties: false
413 additionalProperties: false
446 properties:
414 properties:
@@ -455,7 +423,7 @@ components:
455 - HTTP
423 - HTTP
456 - HTTPS
424 - HTTPS
457 HttpClassCallback:
425 HttpClassCallback:
458− description: "class callback"
426+ title: class callback
459 type: object
427 type: object
460 additionalProperties: false
428 additionalProperties: false
461 properties:
429 properties:
@@ -464,7 +432,7 @@ components:
464 callbackClass:
432 callbackClass:
465 type: string
433 type: string
466 HttpObjectCallback:
434 HttpObjectCallback:
467− description: "object / method callback"
435+ title: object / method callback
468 type: object
436 type: object
469 additionalProperties: false
437 additionalProperties: false
470 properties:
438 properties:
@@ -475,7 +443,7 @@ components:
475 responseCallback:
443 responseCallback:
476 type: boolean
444 type: boolean
477 HttpOverrideForwardedRequest:
445 HttpOverrideForwardedRequest:
478− description: "override forwarded request"
446+ title: override forwarded request
479 oneOf:
447 oneOf:
480 - type: object
448 - type: object
481 additionalProperties: false
449 additionalProperties: false
@@ -577,7 +545,7 @@ components:
577 httpResponse:
545 httpResponse:
578 "$ref": "#/components/schemas/HttpResponse"
546 "$ref": "#/components/schemas/HttpResponse"
579 HttpError:
547 HttpError:
580− description: "error behaviour"
548+ title: error behaviour
581 type: object
549 type: object
582 additionalProperties: false
550 additionalProperties: false
583 properties:
551 properties:
@@ -588,7 +556,7 @@ components:
588 responseBytes:
556 responseBytes:
589 type: string
557 type: string
590 Times:
558 Times:
591− description: "number of responses"
559+ title: "number of responses"
592 type: object
560 type: object
593 additionalProperties: false
561 additionalProperties: false
594 properties:
562 properties:
@@ -597,7 +565,7 @@ components:
597 unlimited:
565 unlimited:
598 type: boolean
566 type: boolean
599 TimeToLive:
567 TimeToLive:
600− description: "time expectation is valid for"
568+ title: "time expectation is valid for"
601 type: object
569 type: object
602 additionalProperties: false
570 additionalProperties: false
603 properties:
571 properties:
@@ -687,7 +655,7 @@ components:
687 # "^\\S+$":
655 # "^\\S+$":
688 # $ref: "#/components/schemas/StringOrJsonSchema"
656 # $ref: "#/components/schemas/StringOrJsonSchema"
689 StringOrJsonSchema:
657 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
691 oneOf:
659 oneOf:
692 - type: string
660 - type: string
693 - type: object
661 - type: object
@@ -718,7 +686,7 @@ components:
718 - PIPE_DELIMITED
686 - PIPE_DELIMITED
719 - DEEP_OBJECT
687 - DEEP_OBJECT
720 SocketAddress:
688 SocketAddress:
721− description: "remote address to send request to, only used for request overrides"
689+ title: remote address to send request to
722 type: object
690 type: object
723 additionalProperties: false
691 additionalProperties: false
724 properties:
692 properties:
@@ -730,198 +698,239 @@ components:
730 enum:
698 enum:
731 - HTTP
699 - HTTP
732 - HTTPS
700 - 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
733 Body:
847 Body:
734 description: "request body matcher"
848 description: "request body matcher"
735 anyOf:
849 anyOf:
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:
736− - type: object
863+ type: object
737− description: "binary body matcher"
864+ description: "binary response body"
738− additionalProperties: false
865+ additionalProperties: false
739− properties:
866+ properties:
740− not:
867+ not:
741− type: boolean
868+ type: boolean
742− type:
869+ type:
743− enum:
870+ enum:
744− - BINARY
871+ - BINARY
745− base64Bytes:
872+ base64Bytes:
746− type: string
873+ type: string
747− contentType:
874+ contentType:
748− type: string
875+ type: string
876+ JsonResponseBody:
749− - type: object
877+ type: object
750− description: "json body matcher"
878+ description: "json response body"
751− additionalProperties: false
879+ additionalProperties: false
752− properties:
880+ properties:
753− not:
881+ not:
754− type: boolean
882+ type: boolean
755− type:
883+ type:
756− enum:
884+ enum:
757− - JSON
885+ - JSON
758− json:
886+ json:
759− type: string
887+ type: string
760− contentType:
888+ contentType:
761− type: string
889+ type: string
762− matchType:
890+ RawJsonResponseBody:
763− enum:
764− - STRICT
765− - ONLY_MATCHING_FIELDS
766− - type: object
891+ type: object
767− description: "json matching fields body matcher"
892+ description: "json response body"
768− additionalProperties: true
893+ additionalProperties: true
769− - type: object
894+ StringResponseBody:
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
895+ type: object
781− description: "JSON path body matcher"
896+ description: "string response body"
782− additionalProperties: false
897+ additionalProperties: false
783− properties:
898+ properties:
784− not:
899+ 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
900+ type: boolean
797− type:
798− enum:
799− - PARAMETERS
800− parameters:
801− $ref: "#/components/schemas/KeyToMultiValue"
802− - type: object
901+ type:
803− description: "regex body matcher"
804− additionalProperties: false
805− properties:
806− not:
807− type: boolean
808− type:
809− enum:
902+ 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
903+ - STRING
822− string:
904+ string:
823− type: string
905+ type: string
824− contentType:
906+ contentType:
825− type: string
907+ type: string
826− subString:
908+ RawStringResponseBody:
827− type: boolean
828− - type: string
909+ type: string
829− description: "substring body matcher"
910+ description: "string response body"
911+ XmlResponseBody:
830− - type: object
912+ type: object
831− description: "xml body matcher"
913+ description: "xml response body"
832− additionalProperties: false
914+ additionalProperties: false
833− properties:
915+ properties:
834− not:
916+ not:
835− type: boolean
917+ type: boolean
836− type:
918+ type:
837− enum:
919+ enum:
838− - XML
920+ - XML
839− xml:
921+ 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
922+ type: string
854− - type: object
923+ contentType:
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
924+ type: string
865 BodyWithContentType:
925 BodyWithContentType:
866 description: "response body"
926 description: "response body"
867 anyOf:
927 anyOf:
868− - type: object
928+ - $ref: "#/components/schemas/BinaryBodyResponse"
869− description: "binary response body"
929+ - $ref: "#/components/schemas/JsonResponseBody"
870− additionalProperties: false
930+ - $ref: "#/components/schemas/RawJsonResponseBody"
871− properties:
931+ - $ref: "#/components/schemas/StringResponseBody"
872− not:
932+ - $ref: "#/components/schemas/RawStringResponseBody"
873− type: boolean
933+ - $ref: "#/components/schemas/XmlResponseBody"
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
925 Delay:
934 Delay:
926 description: "response delay"
935 description: "response delay"
927 type: object
936 type: object
@@ -963,11 +972,6 @@ components:
963 $ref: "#/components/schemas/VerificationTimes"
972 $ref: "#/components/schemas/VerificationTimes"
964 maximumNumberOfRequestToReturnInVerificationFailure:
973 maximumNumberOfRequestToReturnInVerificationFailure:
965 type: integer
974 type: integer
966− oneOf:
967− - required:
968− - expectationId
969− - required:
970− - httpRequest
971 VerificationTimes:
975 VerificationTimes:
972 description: "number of request to verify"
976 description: "number of request to verify"
973 type: object
977 type: object
@@ -993,11 +997,6 @@ components:
993 $ref: "#/components/schemas/RequestDefinition"
997 $ref: "#/components/schemas/RequestDefinition"
994 maximumNumberOfRequestToReturnInVerificationFailure:
998 maximumNumberOfRequestToReturnInVerificationFailure:
995 type: integer
999 type: integer
996− oneOf:
997− - required:
998− - expectationIds
999− - required:
1000− - httpRequests
1001 Ports:
1000 Ports:
1002 description: "list of ports"
1001 description: "list of ports"
1003 type: object
1002 type: object
@@ -1007,14 +1006,3 @@ components:
1007 items:
1006 items:
1008 type: number
1007 type: number
1009 type: array
1008 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
47 MockServer.Types.OpenAPIExpectations
47 MockServer.Types.OpenAPIExpectations
48 MockServer.Types.ParameterBodyMatcher
48 MockServer.Types.ParameterBodyMatcher
49 MockServer.Types.Ports
49 MockServer.Types.Ports
50+ MockServer.Types.Protocol
50 MockServer.Types.RegexBodyMatcher
51 MockServer.Types.RegexBodyMatcher
51 MockServer.Types.RequestDefinition
52 MockServer.Types.RequestDefinition
52 MockServer.Types.SocketAddress
53 MockServer.Types.SocketAddress
@@ -76,6 +77,7 @@ library
76 , http-types
77 , http-types
77 , bytestring
78 , bytestring
78 , aeson
79 , aeson
80+ , openapi3
79 , unordered-containers
81 , unordered-containers
80 , vector
82 , vector
81 , scientific
83 , scientific
@@ -83,3 +85,4 @@ library
83 , mtl
85 , mtl
84 , transformers
86 , transformers
85 default-language: Haskell2010
87 default-language: Haskell2010
88+ default-extensions: DeriveGeneric
src/MockServer.hs+2
@@ -42,6 +42,7 @@ module MockServer (
42 module MockServer.Types.OpenAPIExpectations,
42 module MockServer.Types.OpenAPIExpectations,
43 module MockServer.Types.ParameterBodyMatcher,
43 module MockServer.Types.ParameterBodyMatcher,
44 module MockServer.Types.Ports,
44 module MockServer.Types.Ports,
45+ module MockServer.Types.Protocol,
45 module MockServer.Types.RegexBodyMatcher,
46 module MockServer.Types.RegexBodyMatcher,
46 module MockServer.Types.RequestDefinition,
47 module MockServer.Types.RequestDefinition,
47 module MockServer.Types.SocketAddress,
48 module MockServer.Types.SocketAddress,
@@ -102,6 +103,7 @@ import MockServer.Types.OpenAPIExpectation
102import MockServer.Types.OpenAPIExpectations
103import MockServer.Types.OpenAPIExpectations
103import MockServer.Types.ParameterBodyMatcher
104import MockServer.Types.ParameterBodyMatcher
104import MockServer.Types.Ports
105import MockServer.Types.Ports
106+import MockServer.Types.Protocol
105import MockServer.Types.RegexBodyMatcher
107import MockServer.Types.RegexBodyMatcher
106import MockServer.Types.RequestDefinition
108import MockServer.Types.RequestDefinition
107import MockServer.Types.SocketAddress
109import MockServer.Types.SocketAddress
src/MockServer/Common.hs+23−5
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE LambdaCase #-}
4{-# LANGUAGE LambdaCase #-}
@@ -33,12 +34,18 @@ where
33import qualified Control.Monad.IO.Class as MIO
34import qualified Control.Monad.IO.Class as MIO
34import qualified Control.Monad.Reader as MR
35import qualified Control.Monad.Reader as MR
35import qualified Control.Monad.Trans.Class as MT
36import 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
36import qualified Data.Aeson as Aeson
44import qualified Data.Aeson as Aeson
37import qualified Data.Aeson.Encoding as Encoding
45import qualified Data.Aeson.Encoding as Encoding
38import qualified Data.Bifunctor as BF
46import qualified Data.Bifunctor as BF
39import qualified Data.ByteString.Char8 as B8
47import qualified Data.ByteString.Char8 as B8
40import qualified Data.ByteString.Lazy.Char8 as LB8
48import qualified Data.ByteString.Lazy.Char8 as LB8
41−import qualified Data.HashMap.Strict as HMap
42import qualified Data.Maybe as Maybe
49import qualified Data.Maybe as Maybe
43import qualified Data.Scientific as Scientific
50import qualified Data.Scientific as Scientific
44import Data.Text (Text)
51import Data.Text (Text)
@@ -50,6 +57,15 @@ import qualified Network.HTTP.Client as HC
50import qualified Network.HTTP.Simple as HS
57import qualified Network.HTTP.Simple as HS
51import qualified Network.HTTP.Types as HT
58import qualified Network.HTTP.Types as HT
52
59
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+
53-- | Abstracts the usage of 'Network.HTTP.Simple.httpBS' away,
69-- | Abstracts the usage of 'Network.HTTP.Simple.httpBS' away,
54-- so that it can be used for testing
70-- so that it can be used for testing
55class Monad m => MonadHTTP m where
71class Monad m => MonadHTTP m where
@@ -285,8 +301,10 @@ jsonToFormDataFlat _ Aeson.Null = []
285jsonToFormDataFlat name (Aeson.Number a) = [(name, encodeStrict a)]
301jsonToFormDataFlat name (Aeson.Number a) = [(name, encodeStrict a)]
286jsonToFormDataFlat name (Aeson.String a) = [(name, textToByte a)]
302jsonToFormDataFlat name (Aeson.String a) = [(name, textToByte a)]
287jsonToFormDataFlat name (Aeson.Bool a) = [(name, encodeStrict a)]
303jsonToFormDataFlat name (Aeson.Bool a) = [(name, encodeStrict a)]
304+jsonToFormDataFlat _ (Aeson.Object object) =
288−jsonToFormDataFlat _ (Aeson.Object object) = HMap.toList object >>= uncurry jsonToFormDataFlat . BF.first Just
305+ toList' object >>= uncurry jsonToFormDataFlat . BF.first Just
306+jsonToFormDataFlat name (Aeson.Array vector) =
289−jsonToFormDataFlat name (Aeson.Array vector) = Vector.toList vector >>= jsonToFormDataFlat name
307+ Vector.toList vector >>= jsonToFormDataFlat name
290
308
291-- | creates form data bytestring array
309-- | creates form data bytestring array
292createFormData :: (Aeson.ToJSON a) => a -> [(B8.ByteString, B8.ByteString)]
310createFormData :: (Aeson.ToJSON a) => a -> [(B8.ByteString, B8.ByteString)]
@@ -320,9 +338,9 @@ jsonToFormDataPrefixed prefix (Aeson.Bool False) = [(prefix, "false")]
320jsonToFormDataPrefixed _ Aeson.Null = []
338jsonToFormDataPrefixed _ Aeson.Null = []
321jsonToFormDataPrefixed prefix (Aeson.String a) = [(prefix, a)]
339jsonToFormDataPrefixed prefix (Aeson.String a) = [(prefix, a)]
322jsonToFormDataPrefixed "" (Aeson.Object object) =
340jsonToFormDataPrefixed "" (Aeson.Object object) =
323− HMap.toList object >>= uncurry jsonToFormDataPrefixed
341+ toList' object >>= uncurry jsonToFormDataPrefixed
324jsonToFormDataPrefixed prefix (Aeson.Object object) =
342jsonToFormDataPrefixed prefix (Aeson.Object object) =
325− HMap.toList object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y)
343+ toList' object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y)
326jsonToFormDataPrefixed prefix (Aeson.Array vector) =
344jsonToFormDataPrefixed prefix (Aeson.Array vector) =
327 Vector.toList vector >>= jsonToFormDataPrefixed (prefix <> "[]")
345 Vector.toList vector >>= jsonToFormDataPrefixed (prefix <> "[]")
328
346
src/MockServer/Operations/Put_mockserver_retrieve.hs+2−2
@@ -62,7 +62,7 @@ put_mockserver_retrieve parameters
62data Put_mockserver_retrieveParameters = Put_mockserver_retrieveParameters {
62data Put_mockserver_retrieveParameters = Put_mockserver_retrieveParameters {
63 -- | queryFormat: Represents the parameter named \'format\'
63 -- | queryFormat: Represents the parameter named \'format\'
64 --
64 --
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\"
66 put_mockserver_retrieveParametersQueryFormat :: (GHC.Maybe.Maybe Put_mockserver_retrieveParametersQueryFormat)
66 put_mockserver_retrieveParametersQueryFormat :: (GHC.Maybe.Maybe Put_mockserver_retrieveParametersQueryFormat)
67 -- | queryType: Represents the parameter named \'type\'
67 -- | queryType: Represents the parameter named \'type\'
68 --
68 --
@@ -83,7 +83,7 @@ mkPut_mockserver_retrieveParameters = Put_mockserver_retrieveParameters{put_mock
83--
83--
84-- Represents the parameter named \'format\'
84-- Represents the parameter named \'format\'
85--
85--
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\"
87data Put_mockserver_retrieveParametersQueryFormat =
87data Put_mockserver_retrieveParametersQueryFormat =
88 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.
88 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.
89 | 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.
89 | 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 (
31 module MockServer.Types.OpenAPIExpectations,
31 module MockServer.Types.OpenAPIExpectations,
32 module MockServer.Types.ParameterBodyMatcher,
32 module MockServer.Types.ParameterBodyMatcher,
33 module MockServer.Types.Ports,
33 module MockServer.Types.Ports,
34+ module MockServer.Types.Protocol,
34 module MockServer.Types.RegexBodyMatcher,
35 module MockServer.Types.RegexBodyMatcher,
35 module MockServer.Types.RequestDefinition,
36 module MockServer.Types.RequestDefinition,
36 module MockServer.Types.SocketAddress,
37 module MockServer.Types.SocketAddress,
@@ -77,6 +78,7 @@ import MockServer.Types.OpenAPIExpectation
77import MockServer.Types.OpenAPIExpectations
78import MockServer.Types.OpenAPIExpectations
78import MockServer.Types.ParameterBodyMatcher
79import MockServer.Types.ParameterBodyMatcher
79import MockServer.Types.Ports
80import MockServer.Types.Ports
81+import MockServer.Types.Protocol
80import MockServer.Types.RegexBodyMatcher
82import MockServer.Types.RegexBodyMatcher
81import MockServer.Types.RequestDefinition
83import MockServer.Types.RequestDefinition
82import MockServer.Types.SocketAddress
84import MockServer.Types.SocketAddress
src/MockServer/Types/HttpRequest.hs+7−3
@@ -35,6 +35,7 @@ import MockServer.TypeAlias
35import {-# SOURCE #-} MockServer.Types.Body
35import {-# SOURCE #-} MockServer.Types.Body
36import {-# SOURCE #-} MockServer.Types.KeyToMultiValue
36import {-# SOURCE #-} MockServer.Types.KeyToMultiValue
37import {-# SOURCE #-} MockServer.Types.KeyToValue
37import {-# SOURCE #-} MockServer.Types.KeyToValue
38+import {-# SOURCE #-} MockServer.Types.Protocol
38import {-# SOURCE #-} MockServer.Types.SocketAddress
39import {-# SOURCE #-} MockServer.Types.SocketAddress
39import {-# SOURCE #-} MockServer.Types.StringOrJsonSchema
40import {-# SOURCE #-} MockServer.Types.StringOrJsonSchema
40
41
@@ -56,6 +57,8 @@ data HttpRequest = HttpRequest {
56 , httpRequestPath :: (GHC.Maybe.Maybe StringOrJsonSchema)
57 , httpRequestPath :: (GHC.Maybe.Maybe StringOrJsonSchema)
57 -- | pathParameters
58 -- | pathParameters
58 , httpRequestPathParameters :: (GHC.Maybe.Maybe KeyToMultiValue)
59 , httpRequestPathParameters :: (GHC.Maybe.Maybe KeyToMultiValue)
60+ -- | protocol: protocol matcher
61+ , httpRequestProtocol :: (GHC.Maybe.Maybe Protocol)
59 -- | queryStringParameters
62 -- | queryStringParameters
60 , httpRequestQueryStringParameters :: (GHC.Maybe.Maybe KeyToMultiValue)
63 , httpRequestQueryStringParameters :: (GHC.Maybe.Maybe KeyToMultiValue)
61 -- | secure
64 -- | secure
@@ -65,10 +68,10 @@ data HttpRequest = HttpRequest {
65 } deriving (GHC.Show.Show
68 } deriving (GHC.Show.Show
66 , GHC.Classes.Eq)
69 , GHC.Classes.Eq)
67instance Data.Aeson.Types.ToJSON.ToJSON HttpRequest
70instance 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))
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))
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)))
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)))
70instance Data.Aeson.Types.FromJSON.FromJSON HttpRequest
73instance 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"))
72-- | Create a new 'HttpRequest' with all required fields.
75-- | Create a new 'HttpRequest' with all required fields.
73mkHttpRequest :: HttpRequest
76mkHttpRequest :: HttpRequest
74mkHttpRequest = HttpRequest{httpRequestBody = GHC.Maybe.Nothing,
77mkHttpRequest = HttpRequest{httpRequestBody = GHC.Maybe.Nothing,
@@ -78,6 +81,7 @@ mkHttpRequest = HttpRequest{httpRequestBody = GHC.Maybe.Nothing,
78 httpRequestMethod = GHC.Maybe.Nothing,
81 httpRequestMethod = GHC.Maybe.Nothing,
79 httpRequestPath = GHC.Maybe.Nothing,
82 httpRequestPath = GHC.Maybe.Nothing,
80 httpRequestPathParameters = GHC.Maybe.Nothing,
83 httpRequestPathParameters = GHC.Maybe.Nothing,
84+ httpRequestProtocol = GHC.Maybe.Nothing,
81 httpRequestQueryStringParameters = GHC.Maybe.Nothing,
85 httpRequestQueryStringParameters = GHC.Maybe.Nothing,
82 httpRequestSecure = GHC.Maybe.Nothing,
86 httpRequestSecure = GHC.Maybe.Nothing,
83 httpRequestSocketAddress = GHC.Maybe.Nothing}
87 httpRequestSocketAddress = GHC.Maybe.Nothing}
src/MockServer/Types/JsonSchemaBodyMatcher.hs+6−6
@@ -6,20 +6,19 @@
6-- | Contains the types generated from the schema JsonSchemaBodyMatcher
6-- | Contains the types generated from the schema JsonSchemaBodyMatcher
7module MockServer.Types.JsonSchemaBodyMatcher where
7module MockServer.Types.JsonSchemaBodyMatcher where
8
8
9−import qualified Prelude as GHC.Integer.Type
10−import qualified Prelude as GHC.Maybe
11import qualified Control.Monad.Fail
9import qualified Control.Monad.Fail
12import qualified Data.Aeson
10import qualified Data.Aeson
13import qualified Data.Aeson as Data.Aeson.Encoding.Internal
11import qualified Data.Aeson as Data.Aeson.Encoding.Internal
14import qualified Data.Aeson as Data.Aeson.Types
12import qualified Data.Aeson as Data.Aeson.Types
15import qualified Data.Aeson as Data.Aeson.Types.FromJSON
13import qualified Data.Aeson as Data.Aeson.Types.FromJSON
16−import qualified Data.Aeson as Data.Aeson.Types.ToJSON
17import qualified Data.Aeson as Data.Aeson.Types.Internal
14import qualified Data.Aeson as Data.Aeson.Types.Internal
15+import qualified Data.Aeson as Data.Aeson.Types.ToJSON
18import qualified Data.ByteString.Char8
16import qualified Data.ByteString.Char8
19import qualified Data.ByteString.Char8 as Data.ByteString.Internal
17import qualified Data.ByteString.Char8 as Data.ByteString.Internal
20import qualified Data.Foldable
18import qualified Data.Foldable
21import qualified Data.Functor
19import qualified Data.Functor
22import qualified Data.Maybe
20import qualified Data.Maybe
21+import Data.OpenApi.Internal (Schema)
23import qualified Data.Scientific
22import qualified Data.Scientific
24import qualified Data.Text
23import qualified Data.Text
25import qualified Data.Text.Internal
24import qualified Data.Text.Internal
@@ -32,14 +31,15 @@ import qualified GHC.Show
32import qualified GHC.Types
31import qualified GHC.Types
33import qualified MockServer.Common
32import qualified MockServer.Common
34import MockServer.TypeAlias
33import 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
36
36
37-- | Defines the object schema located at @components.schemas.JsonSchemaBodyMatcher@ in the specification.
37-- | Defines the object schema located at @components.schemas.JsonSchemaBodyMatcher@ in the specification.
38−--
38+--
39-- json schema body matcher
39-- json schema body matcher
40data JsonSchemaBodyMatcher = JsonSchemaBodyMatcher {
40data JsonSchemaBodyMatcher = JsonSchemaBodyMatcher {
41 -- | jsonSchema
41 -- | jsonSchema
42− jsonSchemaBodyMatcherJsonSchema :: (GHC.Maybe.Maybe Http___json_schema'org_draft_04_schema)
42+ jsonSchemaBodyMatcherJsonSchema :: (GHC.Maybe.Maybe Schema)
43 -- | not
43 -- | not
44 , jsonSchemaBodyMatcherNot :: (GHC.Maybe.Maybe GHC.Types.Bool)
44 , jsonSchemaBodyMatcherNot :: (GHC.Maybe.Maybe GHC.Types.Bool)
45 -- | type
45 -- | 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 @@
6-- | Contains the types generated from the schema StringOrJsonSchema
6-- | Contains the types generated from the schema StringOrJsonSchema
7module MockServer.Types.StringOrJsonSchema where
7module MockServer.Types.StringOrJsonSchema where
8
8
9−import qualified Prelude as GHC.Integer.Type
10−import qualified Prelude as GHC.Maybe
11import qualified Control.Monad.Fail
9import qualified Control.Monad.Fail
12import qualified Data.Aeson
10import qualified Data.Aeson
13import qualified Data.Aeson as Data.Aeson.Encoding.Internal
11import qualified Data.Aeson as Data.Aeson.Encoding.Internal
14import qualified Data.Aeson as Data.Aeson.Types
12import qualified Data.Aeson as Data.Aeson.Types
15import qualified Data.Aeson as Data.Aeson.Types.FromJSON
13import qualified Data.Aeson as Data.Aeson.Types.FromJSON
16−import qualified Data.Aeson as Data.Aeson.Types.ToJSON
17import qualified Data.Aeson as Data.Aeson.Types.Internal
14import qualified Data.Aeson as Data.Aeson.Types.Internal
15+import qualified Data.Aeson as Data.Aeson.Types.ToJSON
18import qualified Data.ByteString.Char8
16import qualified Data.ByteString.Char8
19import qualified Data.ByteString.Char8 as Data.ByteString.Internal
17import qualified Data.ByteString.Char8 as Data.ByteString.Internal
20import qualified Data.Foldable
18import qualified Data.Foldable
21import qualified Data.Functor
19import qualified Data.Functor
22import qualified Data.Maybe
20import qualified Data.Maybe
21+import Data.OpenApi.Internal (Schema)
23import qualified Data.Scientific
22import qualified Data.Scientific
24import qualified Data.Text
23import qualified Data.Text
25import qualified Data.Text.Internal
24import qualified Data.Text.Internal
@@ -32,11 +31,12 @@ import qualified GHC.Show
32import qualified GHC.Types
31import qualified GHC.Types
33import qualified MockServer.Common
32import qualified MockServer.Common
34import MockServer.TypeAlias
33import 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
36
36
37-- | Defines the object schema located at @components.schemas.StringOrJsonSchema.oneOf@ in the specification.
37-- | Defines the object schema located at @components.schemas.StringOrJsonSchema.oneOf@ in the specification.
38−--
38+--
39−--
39+--
40data StringOrJsonSchemaOneOf2 = StringOrJsonSchemaOneOf2 {
40data StringOrJsonSchemaOneOf2 = StringOrJsonSchemaOneOf2 {
41 -- | not
41 -- | not
42 stringOrJsonSchemaOneOf2Not :: (GHC.Maybe.Maybe GHC.Types.Bool)
42 stringOrJsonSchemaOneOf2Not :: (GHC.Maybe.Maybe GHC.Types.Bool)
@@ -45,7 +45,7 @@ data StringOrJsonSchemaOneOf2 = StringOrJsonSchemaOneOf2 {
45 -- | parameterStyle
45 -- | parameterStyle
46 , stringOrJsonSchemaOneOf2ParameterStyle :: (GHC.Maybe.Maybe StringOrJsonSchemaOneOf2ParameterStyle)
46 , stringOrJsonSchemaOneOf2ParameterStyle :: (GHC.Maybe.Maybe StringOrJsonSchemaOneOf2ParameterStyle)
47 -- | schema
47 -- | schema
48− , stringOrJsonSchemaOneOf2Schema :: (GHC.Maybe.Maybe Http___json_schema'org_draft_04_schema)
48+ , stringOrJsonSchemaOneOf2Schema :: (GHC.Maybe.Maybe Schema)
49 -- | value
49 -- | value
50 , stringOrJsonSchemaOneOf2Value :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
50 , stringOrJsonSchemaOneOf2Value :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
51 } deriving (GHC.Show.Show
51 } deriving (GHC.Show.Show