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
.gitignore+1
@@ -1 +1,2 @@
1.stack-work
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+11−4
@@ -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
@@ -96,7 +96,7 @@ paths:
96 oneOf:
96 oneOf:
97 - $ref: "#/components/schemas/RequestDefinition"
97 - $ref: "#/components/schemas/RequestDefinition"
98 - $ref: "#/components/schemas/ExpectationId"
98 - $ref: "#/components/schemas/ExpectationId"
99− description: request used to match expectations and recored requests to clear
99+ description: request used to match expectations and record requests to clear
100 /mockserver/reset:
100 /mockserver/reset:
101 put:
101 put:
102 tags:
102 tags:
@@ -116,7 +116,7 @@ paths:
116 schema:
116 schema:
117 type: string
117 type: string
118 enum: [ "java", "json", "log_entries" ]
118 enum: [ "java", "json", "log_entries" ]
119− 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"
120 - in: query
120 - in: query
121 name: type
121 name: type
122 schema:
122 schema:
@@ -363,6 +363,8 @@ components:
363 $ref: "#/components/schemas/KeyToValue"
363 $ref: "#/components/schemas/KeyToValue"
364 socketAddress:
364 socketAddress:
365 $ref: "#/components/schemas/SocketAddress"
365 $ref: "#/components/schemas/SocketAddress"
366+ protocol:
367+ $ref: "#/components/schemas/Protocol"
366 OpenAPIDefinition:
368 OpenAPIDefinition:
367 title: "open api or swagger request matcher"
369 title: "open api or swagger request matcher"
368 type: object
370 type: object
@@ -837,6 +839,11 @@ components:
837 - XPATH
839 - XPATH
838 xpath:
840 xpath:
839 type: string
841 type: string
842+ Protocol:
843+ description: "protocol matcher"
844+ enum:
845+ - HTTP_1_1
846+ - HTTP_2
840 Body:
847 Body:
841 description: "request body matcher"
848 description: "request body matcher"
842 anyOf:
849 anyOf:
stack-lts-19.33.yaml → ghc-9.0.2.yamlrenamed

The content is the same.

stack-lts-19.33.yaml.lock → ghc-9.0.2.yaml.lockrenamed

The content is the same.

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+1
@@ -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
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/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/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