outofcoffee / imposter

Scriptable, multipurpose mock server. Run standalone mock servers, or embed mocks within your tests.
https://imposter.sh
Other
371 stars 60 forks source link

issue in case of multiple matching #449

Closed medaoutir closed 1 year ago

medaoutir commented 1 year ago

Hi I have a scenario when two request matches the yaml config with openapi plugin: this is yaml config when searching for deposit accounts:

resources:
  - path: "/deposits:search"
    method: POST
    queryParams:
      detailsLevel: FULL
    requestBody:
      allOf:
        - jsonPath: $.filterCriteria[0].field
          value: _Card_Deposit_Accounts.ACCOUNT_CARD_ID
        - jsonPath: $.filterCriteria[0].operator
          value: EQUALS
        - jsonPath: $.filterCriteria[0].value
          value: 22578490
    response:
      exampleName: accountExtendedCreated
  - path: "/deposits:search"
    method: POST
    queryParams:
      detailsLevel: FULL
    requestBody:
      allOf:
        - jsonPath: $.filterCriteria[0].field
          value: _Card_Deposit_Accounts.ACCOUNT_CARD_ID
        - jsonPath: $.filterCriteria[0].operator
          value: EQUALS
        - jsonPath: $.filterCriteria[0].value
          value: 22578492
    response:
      exampleName: accountExtendedCreatedWhenBlocking

And below the openapi spec that corresponds to the above config:

/deposits:search:
    post:
      tags:
        - DepositAccounts
      summary: Allows retrieval of deposit accounts using search parameters.
      operationId: search
      parameters:
        - name: offset
          in: query
          description: Pagination, index to start searching at when retrieving elements,
            used in combination with limit to paginate results
          schema:
            type: integer
            format: int32
        - name: limit
          in: query
          description: Pagination, the number of elements to retrieve, used in combination
            with offset to paginate results
          schema:
            type: integer
            format: int32
        - name: paginationDetails
          in: query
          description: Flag specifying whether the pagination  details should be provided
            in response headers. Please note that by default it is disabled (OFF), in
            order to improve the performance of the APIs
          schema:
            type: string
            default: OFF
            enum:
              - ON
              - OFF
        - name: detailsLevel
          in: query
          description: The level of details to retrieve, FULL means the full details
            of the object will be retrieved (custom fields, address, contact info or
            any other related object), BASIC will return only the first level elements
            of the object
          schema:
            type: string
            enum:
              - BASIC
              - FULL
      requestBody:
        description: Criteria to be used to search the deposit accounts
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DepositAccountSearchCriteria'
        required: true
      responses:
        201:
          description: Result of deposit account search
          headers:
            Items-Offset:
              description: Pagination details, the index of the first returned item
              schema:
                type: integer
                format: int32
            Items-Limit:
              description: Pagination details, the requested page size
              schema:
                type: integer
                format: int32
            Items-Total:
              description: Pagination details, the total available items
              schema:
                type: integer
                format: int32
          content:
            application/json:
              examples:
                accountExtendedCreated:
                  value: |-
                    [
                       {
                          "encodedKey":"5b853e007ba05e8a017acac995d34029",
                          "id":"string",
                          "name":"string",
                          "notes":"string",
                          "balances":{
                             "totalBalance":0,
                             "lockedBalance":0,
                             "holdBalance":0,
                             "blockedBalance":0,
                             "availableBalance":0
                          },
                          "accountType":"string",
                          "creationDate":"2016-09-06T13:37:50+03:00",
                          "approvedDate":"2016-09-06T13:37:50+03:00",
                          "accountHolderKey":"string",
                          "productTypeKey":"string",
                          "activationDate":"2016-09-06T13:37:50+03:00",
                          "currencyCode":"string",
                          "accountHolderType":"string",
                          "accountState":"string",
                          "_Deposit_Details_Deposit_Account":{
                             "BELONGS_TO_ACCOUNT":"string",
                             "ACCOUNT_MOBILE_NUMBER":"string",
                             "ACCOUNT_EMAIL_ADDRESS":"string",
                             "ACCOUNT_PROFILE":"string",
                             "ACCOUNT_DISTRIBUTOR":"string",
                             "ACCOUNT_NOTIFICATION_OPERATION":"string",
                             "ACCOUNT_STATIC_PASSWORD":"string",
                             "ACCOUNT_PROGRAM_UUID":"string",
                             "ACCOUNT_PROGRAM_NAME":"string",
                             "ACCOUNT_DISTRIBUTOR_UUID":"string",
                             "ACCOUNT_DISTRIBUTOR_NAME":"string",
                             "ACCOUNT_COMPANY_ID":"string",
                             "ACCOUNT_PERSON_NAME":"string",
                             "ACCOUNT_PERSON_LAST_NAME":"string",
                             "ACCOUNT_LINKED_REAL_PERSON":"string"
                          },
                          "_Card_Deposit_Accounts":[
                             {
                                "ACCOUNT_CARD_ID":"22578490",
                                "ACCOUNT_CARD_TYPE":"string",
                                "ACCOUNT_CARD_CREATION_DATE":"2016-09-01T13:37:50+03:00",
                                "ACCOUNT_CARD_STATUS_ID":"string",
                                "ACCOUNT_MPTS_CARD_ID":"string",
                                "ACCOUNT_CARD_EXPIRY_DATE_YYMM":"2023-08-01",
                                "ACCOUNT_CARD_IDENTIFICATION_CODE":"string",
                                "ACCOUNT_CARD_PSN":"string",
                                "ACCOUNT_CARD_IIN_ID":"string",
                                "ACCOUNT_CARD_LAST_4_ID":"string",
                                "ACCOUNT_CARD_PROCESSOR":"string",
                                "ACCOUNT_CARD_ORDER_REF":"string",
                                "ACCOUNT_CARD_FLOW_STATE":"string",
                                "ACCOUNT_CARD_CONTACT_LESS":"string",
                                "_index":"string",
                                "ACCOUNT_CARD_EXPEDITION_FLAG":"string",
                                "ONE_TIME_REFILL":false,
                                "ACCOUNT_RECHARGED":false
                             }
                          ],
                          "_Bank_Account_Detail_Deposit_Acc":{
                             "BANK_ACCOUNT_NUMBER":"string",
                             "BIC_CODE":"string",
                             "BANK_ACCOUNT_NAME":"string",
                             "IBAN_VERIFIED":"string"
                          },
                          "_Deposit_MptsInfo":{
                             "DEPOSIT_ACCOUNT_ID":"string",
                             "DEPOSIT_CLIENT_ID":"string"
                          },
                          "_Deposit_BomusInfo":{
                             "DEPOSIT_BOMUS_ID":"string"
                          }
                       }
                    ]
                accountExtendedCreatedWhenBlocking:
                  value: |-
                    [
                       {
                          "encodedKey":"5b853e007ba05e8a017acac995d34030",
                          "id":"string",
                          "name":"string",
                          "notes":"string",
                          "balances":{
                             "totalBalance":0,
                             "lockedBalance":0,
                             "holdBalance":0,
                             "blockedBalance":0,
                             "availableBalance":0
                          },
                          "accountType":"string",
                          "creationDate":"2016-09-06T13:37:50+03:00",
                          "approvedDate":"2016-09-06T13:37:50+03:00",
                          "accountHolderKey":"string",
                          "productTypeKey":"string",
                          "activationDate":"2016-09-06T13:37:50+03:00",
                          "currencyCode":"string",
                          "accountHolderType":"string",
                          "accountState":"string",
                          "_Deposit_Details_Deposit_Account":{
                             "BELONGS_TO_ACCOUNT":"string",
                             "ACCOUNT_MOBILE_NUMBER":"string",
                             "ACCOUNT_EMAIL_ADDRESS":"string",
                             "ACCOUNT_PROFILE":"string",
                             "ACCOUNT_DISTRIBUTOR":"string",
                             "ACCOUNT_NOTIFICATION_OPERATION":"string",
                             "ACCOUNT_STATIC_PASSWORD":"string",
                             "ACCOUNT_PROGRAM_UUID":"string",
                             "ACCOUNT_PROGRAM_NAME":"string",
                             "ACCOUNT_DISTRIBUTOR_UUID":"string",
                             "ACCOUNT_DISTRIBUTOR_NAME":"string",
                             "ACCOUNT_COMPANY_ID":"string",
                             "ACCOUNT_PERSON_NAME":"string",
                             "ACCOUNT_PERSON_LAST_NAME":"string",
                             "ACCOUNT_LINKED_REAL_PERSON":"string"
                          },
                          "_Card_Deposit_Accounts":[
                             {
                                "ACCOUNT_CARD_ID":"22578492",
                                "ACCOUNT_CARD_TYPE":"string",
                                "ACCOUNT_CARD_CREATION_DATE":"2016-09-01T13:37:50+03:00",
                                "ACCOUNT_CARD_STATUS_ID":"string",
                                "ACCOUNT_MPTS_CARD_ID":"string",
                                "ACCOUNT_CARD_EXPIRY_DATE_YYMM":"2023-08-01",
                                "ACCOUNT_CARD_IDENTIFICATION_CODE":"string",
                                "ACCOUNT_CARD_PSN":"string",
                                "ACCOUNT_CARD_IIN_ID":"string",
                                "ACCOUNT_CARD_LAST_4_ID":"string",
                                "ACCOUNT_CARD_PROCESSOR":"string",
                                "ACCOUNT_CARD_ORDER_REF":"string",
                                "ACCOUNT_CARD_FLOW_STATE":"string",
                                "ACCOUNT_CARD_CONTACT_LESS":"string",
                                "_index":"string",
                                "ACCOUNT_CARD_EXPEDITION_FLAG":"string",
                                "ONE_TIME_REFILL":false,
                                "ACCOUNT_RECHARGED":false
                             }
                          ],
                          "_Bank_Account_Detail_Deposit_Acc":{
                             "BANK_ACCOUNT_NUMBER":"string",
                             "BIC_CODE":"string",
                             "BANK_ACCOUNT_NAME":"string",
                             "IBAN_VERIFIED":"string"
                          },
                          "_Deposit_MptsInfo":{
                             "DEPOSIT_ACCOUNT_ID":"string",
                             "DEPOSIT_CLIENT_ID":"string"
                          },
                          "_Deposit_BomusInfo":{
                             "DEPOSIT_BOMUS_ID":"string"
                          }
                       }
                    ]

              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DepositAccount'
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{{
    "filterCriteria": [
        {
            "field": "_Card_Deposit_Accounts.ACCOUNT_CARD_ID",
            "operator": "EQUALS",
            "value": "22578492",
            "secondValue": null,
            "values": null
        }
    ],
    "sortingCriteria": null}}'  \
http://localhost:8090/api/deposits:search?detailsLevel=FULL

I get the response:

[
    {
        "encodedKey": "5b853e007ba05e8a017acac995d34029",
        "id": "string",
        "name": "string",
        "notes": "string",
        "balances": {
            "totalBalance": 0,
            "lockedBalance": 0,
            "holdBalance": 0,
            "blockedBalance": 0,
            "availableBalance": 0
        },
        "accountType": "string",
        "creationDate": "2016-09-06T13:37:50+03:00",
        "approvedDate": "2016-09-06T13:37:50+03:00",
        "accountHolderKey": "string",
        "productTypeKey": "string",
        "activationDate": "2016-09-06T13:37:50+03:00",
        "currencyCode": "string",
        "accountHolderType": "string",
        "accountState": "string",
        "_Deposit_Details_Deposit_Account": {
            "BELONGS_TO_ACCOUNT": "string",
            "ACCOUNT_MOBILE_NUMBER": "string",
            "ACCOUNT_EMAIL_ADDRESS": "string",
            "ACCOUNT_PROFILE": "string",
            "ACCOUNT_DISTRIBUTOR": "string",
            "ACCOUNT_NOTIFICATION_OPERATION": "string",
            "ACCOUNT_STATIC_PASSWORD": "string",
            "ACCOUNT_PROGRAM_UUID": "string",
            "ACCOUNT_PROGRAM_NAME": "string",
            "ACCOUNT_DISTRIBUTOR_UUID": "string",
            "ACCOUNT_DISTRIBUTOR_NAME": "string",
            "ACCOUNT_COMPANY_ID": "string",
            "ACCOUNT_PERSON_NAME": "string",
            "ACCOUNT_PERSON_LAST_NAME": "string",
            "ACCOUNT_LINKED_REAL_PERSON": "string"
        },
        "_Card_Deposit_Accounts": [
            {
                "ACCOUNT_CARD_ID": "22578490",
                "ACCOUNT_CARD_TYPE": "string",
                "ACCOUNT_CARD_CREATION_DATE": "2016-09-01T13:37:50+03:00",
                "ACCOUNT_CARD_STATUS_ID": "string",
                "ACCOUNT_MPTS_CARD_ID": "string",
                "ACCOUNT_CARD_EXPIRY_DATE_YYMM": "2023-08-01",
                "ACCOUNT_CARD_IDENTIFICATION_CODE": "string",
                "ACCOUNT_CARD_PSN": "string",
                "ACCOUNT_CARD_IIN_ID": "string",
                "ACCOUNT_CARD_LAST_4_ID": "string",
                "ACCOUNT_CARD_PROCESSOR": "string",
                "ACCOUNT_CARD_ORDER_REF": "string",
                "ACCOUNT_CARD_FLOW_STATE": "string",
                "ACCOUNT_CARD_CONTACT_LESS": "string",
                "_index": "string",
                "ACCOUNT_CARD_EXPEDITION_FLAG": "string",
                "ONE_TIME_REFILL": false,
                "ACCOUNT_RECHARGED": false
            }
        ],
        "_Bank_Account_Detail_Deposit_Acc": {
            "BANK_ACCOUNT_NUMBER": "string",
            "BIC_CODE": "string",
            "BANK_ACCOUNT_NAME": "string",
            "IBAN_VERIFIED": "string"
        },
        "_Deposit_MptsInfo": {
            "DEPOSIT_ACCOUNT_ID": "string",
            "DEPOSIT_CLIENT_ID": "string"
        },
        "_Deposit_BomusInfo": {
            "DEPOSIT_BOMUS_ID": "string"
        }
    }
]

Which is the first exampleName (accountExtendedCreated) instead of accountExtendedCreatedWhenBlocking exampleName, so the matching is not correct !

Below the imposter log:

2023-08-06 14:02:45 13:02:45 TRACE i.v.e.w.i.RouterImpl - Router: 473655317 accepting request POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.v.e.w.RoutingContext - Route matches: RouteState{metadata=null, path='null', name=null, order=1, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.gatehill.imposter.server.vertxweb.VertxWebServerFactoryImpl$$Lambda$446/0x0000000840677840@4f6a0f2e], failureHandlers=null, added=true, pattern=null, groups=null, useNormalizedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=true} 2023-08-06 14:02:45 13:02:45 TRACE i.v.e.w.RoutingContext - Calling the handler 2023-08-06 14:02:45 13:02:45 TRACE i.v.e.w.RoutingContext - Route matches: RouteState{metadata=null, path='/api/deposits:search', name=null, order=23, enabled=true, methods=[POST], consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.gatehill.imposter.server.vertxweb.VertxWebServerFactoryImpl$$Lambda$446/0x0000000840677840@3862ad1e], failureHandlers=null, added=true, pattern=/api/deposits(?[^/]+)/?, groups=[search], useNormalizedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=true} 2023-08-06 14:02:45 13:02:45 TRACE i.v.e.w.RoutingContext - Calling the handler 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Matching against all of 3 request body configs for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL: [BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].field, xPath=null, xmlNamespaces=null, value=_Card_Deposit_Accounts.ACCOUNT_CARD_ID, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].operator, xPath=null, xmlNamespaces=null, value=EQUALS, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].value, xPath=null, xmlNamespaces=null, value=22578490, operator=null)] 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '_Card_Deposit_Accounts.ACCOUNT_CARD_ID': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo 'EQUALS': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '22578490': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Result of matching request [d70ac759-1715-46cc-aec1-a5216497cc99] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits:search, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@1185495e, exampleName=accountExtendedCreated)), method=POST, pathParams=null, queryParams={detailsLevel=FULL}, formParams=null, requestHeaders=null, requestBody=BaseRequestBodyConfig(jsonPath=null, xPath=null, xmlNamespaces=null, value=null, operator=null), eval=null, passthrough=null), path=/deposits:search, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@1185495e, exampleName=accountExtendedCreated)): MatchedResource(resource=io.gatehill.imposter.config.ResolvedResourceConfig@5108e17b, matched=false, score=2, exact=false) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Matching against all of 3 request body configs for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL: [BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].field, xPath=null, xmlNamespaces=null, value=_Card_Deposit_Accounts.ACCOUNT_CARD_ID, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].operator, xPath=null, xmlNamespaces=null, value=EQUALS, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].value, xPath=null, xmlNamespaces=null, value=22578492, operator=null)] 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '_Card_Deposit_Accounts.ACCOUNT_CARD_ID': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo 'EQUALS': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '22578492': ResourceMatchResult(type=NOT_MATCHED, weight=0) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Result of matching request [d70ac759-1715-46cc-aec1-a5216497cc99] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits:search, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@1e142616, exampleName=accountExtendedCreatedWhenBlocking)), method=POST, pathParams=null, queryParams={detailsLevel=FULL}, formParams=null, requestHeaders=null, requestBody=BaseRequestBodyConfig(jsonPath=null, xPath=null, xmlNamespaces=null, value=null, operator=null), eval=null, passthrough=null), path=/deposits:search, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@1e142616, exampleName=accountExtendedCreatedWhenBlocking)): MatchedResource(resource=io.gatehill.imposter.config.ResolvedResourceConfig@2f54633e, matched=false, score=2, exact=false) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - No request body config to match for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Result of matching request [d70ac759-1715-46cc-aec1-a5216497cc99] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits/:depositAccountId, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@1cdb40b3, exampleName=null)), method=PATCH, pathParams={depositAccountId=5b853e007ba05e8a017acac995d34029}, queryParams=null, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=null, eval=null, passthrough=null), path=/deposits/:depositAccountId, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@1cdb40b3, exampleName=null)): MatchedResource(resource=io.gatehill.imposter.config.ResolvedResourceConfig@a4e796a, matched=false, score=1, exact=false) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - No request body config to match for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - Result of matching request [d70ac759-1715-46cc-aec1-a5216497cc99] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits/:depositAccountId, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@35d5daa3, exampleName=null)), method=PATCH, pathParams={depositAccountId=5b853e007ba05e8a017acac995d34030}, queryParams=null, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=null, eval=null, passthrough=null), path=/deposits/:depositAccountId, responseConfig=OpenApiResponseConfig(parent=io.gatehill.imposter.plugin.openapi.config.OpenApiResponseConfig@35d5daa3, exampleName=null)): MatchedResource(resource=io.gatehill.imposter.config.ResolvedResourceConfig@399402b4, matched=false, score=1, exact=false) 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.h.AbstractResourceMatcher - No matching resource config for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.s.s.SecurityLifecycleListenerImpl - No security policy found for: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.p.o.OpenApiPluginImpl - Operation search matched for request: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 DEBUG i.g.i.p.o.s.SpecificationServiceImpl - Validation passed for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.s.ResponseRoutingServiceImpl - Using default HTTP 201 response behaviour for request: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 DEBUG i.g.i.p.o.OpenApiPluginImpl - Setting content type [application/json] from specification for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.s.ResponseServiceImpl - Sending mock response for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL with status code 201 2023-08-06 14:02:45 13:02:45 WARN i.g.i.s.ResponseServiceImpl - Response file and data are blank for [d70ac759-1715-46cc-aec1-a5216497cc99] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.p.o.s.ExampleServiceImpl - Using inline response 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.p.o.s.ExampleServiceImpl - Checking for mock example in specification (2 candidates) for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-06 14:02:45 13:02:45 DEBUG i.g.i.p.o.s.ExampleServiceImpl - No exact match found for accepted content types - choosing first item found (application/json) from specification. You can switch off this behaviour by setting configuration option 'pickFirstIfNoneMatch: false' 2023-08-06 14:02:45 13:02:45 TRACE i.g.i.p.o.s.ResponseTransmissionServiceImpl - Serving mock example for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL with status code 201: [ 2023-08-06 14:02:45 { 2023-08-06 14:02:45 "encodedKey":"5b853e007ba05e8a017acac995d34029", 2023-08-06 14:02:45 "id":"string", 2023-08-06 14:02:45 "name":"string", 2023-08-06 14:02:45 "notes":"string", 2023-08-06 14:02:45 "balances":{ 2023-08-06 14:02:45 "totalBalance":0, 2023-08-06 14:02:45 "lockedBalance":0, 2023-08-06 14:02:45 "holdBalance":0, 2023-08-06 14:02:45 "blockedBalance":0, 2023-08-06 14:02:45 "availableBalance":0 2023-08-06 14:02:45 }, 2023-08-06 14:02:45 "accountType":"string", 2023-08-06 14:02:45 "creationDate":"2016-09-06T13:37:50+03:00", 2023-08-06 14:02:45 "approvedDate":"2016-09-06T13:37:50+03:00", 2023-08-06 14:02:45 "accountHolderKey":"string", 2023-08-06 14:02:45 "productTypeKey":"string", 2023-08-06 14:02:45 "activationDate":"2016-09-06T13:37:50+03:00", 2023-08-06 14:02:45 "currencyCode":"string", 2023-08-06 14:02:45 "accountHolderType":"string", 2023-08-06 14:02:45 "accountState":"string", 2023-08-06 14:02:45 "_Deposit_Details_Deposit_Account":{ 2023-08-06 14:02:45 "BELONGS_TO_ACCOUNT":"string", 2023-08-06 14:02:45 "ACCOUNT_MOBILE_NUMBER":"string", 2023-08-06 14:02:45 "ACCOUNT_EMAIL_ADDRESS":"string", 2023-08-06 14:02:45 "ACCOUNT_PROFILE":"string", 2023-08-06 14:02:45 "ACCOUNT_DISTRIBUTOR":"string", 2023-08-06 14:02:45 "ACCOUNT_NOTIFICATION_OPERATION":"string", 2023-08-06 14:02:45 "ACCOUNT_STATIC_PASSWORD":"string", 2023-08-06 14:02:45 "ACCOUNT_PROGRAM_UUID":"string", 2023-08-06 14:02:45 "ACCOUNT_PROGRAM_NAME":"string", 2023-08-06 14:02:45 "ACCOUNT_DISTRIBUTOR_UUID":"string", 2023-08-06 14:02:45 "ACCOUNT_DISTRIBUTOR_NAME":"string", 2023-08-06 14:02:45 "ACCOUNT_COMPANY_ID":"string", 2023-08-06 14:02:45 "ACCOUNT_PERSON_NAME":"string", 2023-08-06 14:02:45 "ACCOUNT_PERSON_LAST_NAME":"string", 2023-08-06 14:02:45 "ACCOUNT_LINKED_REAL_PERSON":"string" 2023-08-06 14:02:45 }, 2023-08-06 14:02:45 "_Card_Deposit_Accounts":[ 2023-08-06 14:02:45 { 2023-08-06 14:02:45 "ACCOUNT_CARD_ID":"22578490", 2023-08-06 14:02:45 "ACCOUNT_CARD_TYPE":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_CREATION_DATE":"2016-09-01T13:37:50+03:00", 2023-08-06 14:02:45 "ACCOUNT_CARD_STATUS_ID":"string", 2023-08-06 14:02:45 "ACCOUNT_MPTS_CARD_ID":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_EXPIRY_DATE_YYMM":"2023-08-01", 2023-08-06 14:02:45 "ACCOUNT_CARD_IDENTIFICATION_CODE":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_PSN":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_IIN_ID":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_LAST_4_ID":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_PROCESSOR":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_ORDER_REF":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_FLOW_STATE":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_CONTACT_LESS":"string", 2023-08-06 14:02:45 "_index":"string", 2023-08-06 14:02:45 "ACCOUNT_CARD_EXPEDITION_FLAG":"string", 2023-08-06 14:02:45 "ONE_TIME_REFILL":false, 2023-08-06 14:02:45 "ACCOUNT_RECHARGED":false 2023-08-06 14:02:45 } 2023-08-06 14:02:45 ], 2023-08-06 14:02:45 "_Bank_Account_Detail_Deposit_Acc":{ 2023-08-06 14:02:45 "BANK_ACCOUNT_NUMBER":"string", 2023-08-06 14:02:45 "BIC_CODE":"string", 2023-08-06 14:02:45 "BANK_ACCOUNT_NAME":"string", 2023-08-06 14:02:45 "IBAN_VERIFIED":"string" 2023-08-06 14:02:45 }, 2023-08-06 14:02:45 "_Deposit_MptsInfo":{ 2023-08-06 14:02:45 "DEPOSIT_ACCOUNT_ID":"string", 2023-08-06 14:02:45 "DEPOSIT_CLIENT_ID":"string" 2023-08-06 14:02:45 }, 2023-08-06 14:02:45 "_Deposit_BomusInfo":{ 2023-08-06 14:02:45 "DEPOSIT_BOMUS_ID":"string" 2023-08-06 14:02:45 } 2023-08-06 14:02:45 } 2023-08-06 14:02:45 ]

Is there any way for exact matching feature for example ? for this scenario the second example is always ignored (accountExtendedCreatedWhenBlocking) ? by default the imposter render the first example (accountExtendedCreated) !

Thanks in advance for your help

medaoutir commented 1 year ago

Hi @outofcoffee have you a time slot to resolve my issue please ?

outofcoffee commented 1 year ago

Hi @medaoutir, thanks very much for raising this.

There is a bug prior to v3.28.1 that would cause incorrect matching behaviour on the request body. This was especially pronounced when using the allOf or anyOf clauses.

I hope this helps. Please could you let us know if this fixes the issue?


On a related note, you can set this option to disable the fallback when there are multiple candidate matches:

pickFirstIfNoneMatch: false

See log entry:

2023-08-06 14:02:45 13:02:45 DEBUG i.g.i.p.o.s.ExampleServiceImpl - No exact match found for accepted content types - choosing first item found (application/json) from specification. You can switch off this behaviour by setting configuration option 'pickFirstIfNoneMatch: false'
medaoutir commented 1 year ago

Thanks for your answer @outofcoffee but The same error still occurs, always the mockserver render the first example as described in my first issue, but I think that the scoring algorithm has changed. Just notice that I have completly removed the image and rebuild it to get the v3.28.1 that brings your correction. Below the imposter log:

2023-08-07 14:27:36 13:27:36 TRACE i.v.e.w.i.RouterImpl - Router: 30400646 accepting request POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.v.e.w.RoutingContext - Route matches: RouteState{metadata=null, path='null', name=null, order=1, enabled=true, methods=null, consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.gatehill.imposter.server.vertxweb.VertxWebServerFactoryImpl$$Lambda$446/0x0000000840687840@4281acf8], failureHandlers=null, added=true, pattern=null, groups=null, useNormalizedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=true} 2023-08-07 14:27:36 13:27:36 TRACE i.v.e.w.RoutingContext - Calling the handler 2023-08-07 14:27:36 13:27:36 TRACE i.v.e.w.RoutingContext - Route matches: RouteState{metadata=null, path='/api/deposits:search', name=null, order=23, enabled=true, methods=[POST], consumes=null, emptyBodyPermittedWithConsumes=false, produces=null, contextHandlers=[io.gatehill.imposter.server.vertxweb.VertxWebServerFactoryImpl$$Lambda$446/0x0000000840687840@60d03fa1], failureHandlers=null, added=true, pattern=/api/deposits(?[^/]+)/?, groups=[search], useNormalizedPath=true, namedGroupsInRegex=null, virtualHostPattern=null, pathEndsWithSlash=false, exclusive=false, exactPath=true} 2023-08-07 14:27:36 13:27:36 TRACE i.v.e.w.RoutingContext - Calling the handler 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Matching against all of 3 request body configs for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL: [BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].field, xPath=null, xmlNamespaces=null, value=_Card_Deposit_Accounts.ACCOUNT_CARD_ID, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].operator, xPath=null, xmlNamespaces=null, value=EQUALS, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].value, xPath=null, xmlNamespaces=null, value=22578490, operator=null)] 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '_Card_Deposit_Accounts.ACCOUNT_CARD_ID': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo 'EQUALS': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '22578490': ResourceMatchResult(type=NOT_MATCHED, weight=0) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Request match evaluation for '[86cdf404-6284-4a9a-8ab8-0dc1ddeb647c] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL' to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits:search, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreated)), method=POST, pathParams=null, queryParams={detailsLevel=FULL}, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=BaseRequestBodyConfig(jsonPath=null, xPath=null, xmlNamespaces=null, value=null, operator=null), eval=null, passthrough=null), path=/deposits:search, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreated)), from results: [ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NO_CONFIG, weight=1)], outcome: MatchedResource(resource=ResolvedResourceConfig(config=OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits:search, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreated)), method=POST, pathParams=null, queryParams={detailsLevel=FULL}, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=BaseRequestBodyConfig(jsonPath=null, xPath=null, xmlNamespaces=null, value=null, operator=null), eval=null, passthrough=null), path=/deposits:search, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreated)), pathParams={}, queryParams={detailsLevel=FULL}, formParams={}, requestHeaders={Content-Type=application/json}), matched=false, score=3, exact=false) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Matching against all of 3 request body configs for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL: [BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].field, xPath=null, xmlNamespaces=null, value=_Card_Deposit_Accounts.ACCOUNT_CARD_ID, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].operator, xPath=null, xmlNamespaces=null, value=EQUALS, operator=null), BaseRequestBodyConfig(jsonPath=$.filterCriteria[0].value, xPath=null, xmlNamespaces=null, value=33689503, operator=null)] 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '_Card_Deposit_Accounts.ACCOUNT_CARD_ID': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo 'EQUALS': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Body match result for EqualTo '33689503': ResourceMatchResult(type=EXACT_MATCH, weight=1) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Request match evaluation for '[86cdf404-6284-4a9a-8ab8-0dc1ddeb647c] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL' to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits:search, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreatedWhenBlocking)), method=POST, pathParams=null, queryParams={detailsLevel=FULL}, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=BaseRequestBodyConfig(jsonPath=null, xPath=null, xmlNamespaces=null, value=null, operator=null), eval=null, passthrough=null), path=/deposits:search, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreatedWhenBlocking)), from results: [ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=3), ResourceMatchResult(type=NO_CONFIG, weight=1)], outcome: MatchedResource(resource=ResolvedResourceConfig(config=OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits:search, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreatedWhenBlocking)), method=POST, pathParams=null, queryParams={detailsLevel=FULL}, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=BaseRequestBodyConfig(jsonPath=null, xPath=null, xmlNamespaces=null, value=null, operator=null), eval=null, passthrough=null), path=/deposits:search, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=null, headers=null, performanceDelay=null, failureType=null), exampleName=accountExtendedCreatedWhenBlocking)), pathParams={}, queryParams={detailsLevel=FULL}, formParams={}, requestHeaders={Content-Type=application/json}), matched=false, score=6, exact=false) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - No request body config to match for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Request match evaluation for '[86cdf404-6284-4a9a-8ab8-0dc1ddeb647c] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL' to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits/:depositAccountId, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=204, headers=null, performanceDelay=null, failureType=null), exampleName=null)), method=PATCH, pathParams={depositAccountId=5b853e007ba05e8a017acac995d34029}, queryParams=null, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=null, eval=null, passthrough=null), path=/deposits/:depositAccountId, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=204, headers=null, performanceDelay=null, failureType=null), exampleName=null)), from results: [ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1)], outcome: MatchedResource(resource=ResolvedResourceConfig(config=OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits/:depositAccountId, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=204, headers=null, performanceDelay=null, failureType=null), exampleName=null)), method=PATCH, pathParams={depositAccountId=5b853e007ba05e8a017acac995d34029}, queryParams=null, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=null, eval=null, passthrough=null), path=/deposits/:depositAccountId, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=204, headers=null, performanceDelay=null, failureType=null), exampleName=null)), pathParams={depositAccountId=5b853e007ba05e8a017acac995d34029}, queryParams={}, formParams={}, requestHeaders={Content-Type=application/json}), matched=false, score=1, exact=false) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - No request body config to match for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - Request match evaluation for '[86cdf404-6284-4a9a-8ab8-0dc1ddeb647c] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL' to resource OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits/:depositAccountId, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=400, headers=null, performanceDelay=null, failureType=null), exampleName=null)), method=PATCH, pathParams={depositAccountId=5b853e007ba05e8a017acac995d34030}, queryParams=null, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=null, eval=null, passthrough=null), path=/deposits/:depositAccountId, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=400, headers=null, performanceDelay=null, failureType=null), exampleName=null)), from results: [ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NOT_MATCHED, weight=0), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=EXACT_MATCH, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1), ResourceMatchResult(type=NO_CONFIG, weight=1)], outcome: MatchedResource(resource=ResolvedResourceConfig(config=OpenApiResourceConfig(parent=RestResourceConfig(parent=AbstractResourceConfig(path=/deposits/:depositAccountId, securityConfig=null, captureConfig=null, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=400, headers=null, performanceDelay=null, failureType=null), exampleName=null)), method=PATCH, pathParams={depositAccountId=5b853e007ba05e8a017acac995d34030}, queryParams=null, formParams=null, requestHeaders={Content-Type=application/json}, requestBody=null, eval=null, passthrough=null), path=/deposits/:depositAccountId, responseConfig=OpenApiResponseConfig(parent=ResponseConfig(file=null, content=null, dir=null, isTemplate=null, scriptFile=null, statusCode=400, headers=null, performanceDelay=null, failureType=null), exampleName=null)), pathParams={depositAccountId=5b853e007ba05e8a017acac995d34030}, queryParams={}, formParams={}, requestHeaders={Content-Type=application/json}), matched=false, score=1, exact=false) 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.h.AbstractResourceMatcher - No matching resource config for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.s.s.SecurityLifecycleListenerImpl - No security policy found for: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.p.o.OpenApiPluginImpl - Operation search matched for request: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 DEBUG i.g.i.p.o.s.SpecificationServiceImpl - Validation passed for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.s.ResponseRoutingServiceImpl - 0 processing steps for request: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.s.ResponseRoutingServiceImpl - Using default HTTP 201 response behaviour for request: POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 DEBUG i.g.i.p.o.OpenApiPluginImpl - Setting content type [application/json] from specification for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.s.ResponseServiceImpl - Sending mock response for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL with status code 201 2023-08-07 14:27:36 13:27:36 WARN i.g.i.s.ResponseServiceImpl - Response file and data are blank for [86cdf404-6284-4a9a-8ab8-0dc1ddeb647c] POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.p.o.s.ExampleServiceImpl - Using inline response 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.p.o.s.ExampleServiceImpl - Checking for mock example in specification (2 candidates) for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL 2023-08-07 14:27:36 13:27:36 DEBUG i.g.i.p.o.s.ExampleServiceImpl - No exact match found for accepted content types - choosing first item found (application/json) from specification. You can switch off this behaviour by setting configuration option 'pickFirstIfNoneMatch: false' 2023-08-07 14:27:36 13:27:36 TRACE i.g.i.p.o.s.ResponseTransmissionServiceImpl - Serving mock example for POST http://localhost:8090/api/deposits:search?detailsLevel=FULL with status code 201: [ 2023-08-07 14:27:36 { 2023-08-07 14:27:36 "encodedKey":"5b853e007ba05e8a017acac995d34029", 2023-08-07 14:27:36 "id":"string", 2023-08-07 14:27:36 "name":"string", 2023-08-07 14:27:36 "notes":"string", 2023-08-07 14:27:36 "balances":{ 2023-08-07 14:27:36 "totalBalance":0, 2023-08-07 14:27:36 "lockedBalance":0, 2023-08-07 14:27:36 "holdBalance":0, 2023-08-07 14:27:36 "blockedBalance":0, 2023-08-07 14:27:36 "availableBalance":0 2023-08-07 14:27:36 }, 2023-08-07 14:27:36 "accountType":"string", 2023-08-07 14:27:36 "creationDate":"2016-09-06T13:37:50+03:00", 2023-08-07 14:27:36 "approvedDate":"2016-09-06T13:37:50+03:00", 2023-08-07 14:27:36 "accountHolderKey":"string", 2023-08-07 14:27:36 "productTypeKey":"string", 2023-08-07 14:27:36 "activationDate":"2016-09-06T13:37:50+03:00", 2023-08-07 14:27:36 "currencyCode":"string", 2023-08-07 14:27:36 "accountHolderType":"string", 2023-08-07 14:27:36 "accountState":"string", 2023-08-07 14:27:36 "_Deposit_Details_Deposit_Account":{ 2023-08-07 14:27:36 "BELONGS_TO_ACCOUNT":"string", 2023-08-07 14:27:36 "ACCOUNT_MOBILE_NUMBER":"string", 2023-08-07 14:27:36 "ACCOUNT_EMAIL_ADDRESS":"string", 2023-08-07 14:27:36 "ACCOUNT_PROFILE":"string", 2023-08-07 14:27:36 "ACCOUNT_DISTRIBUTOR":"string", 2023-08-07 14:27:36 "ACCOUNT_NOTIFICATION_OPERATION":"string", 2023-08-07 14:27:36 "ACCOUNT_STATIC_PASSWORD":"string", 2023-08-07 14:27:36 "ACCOUNT_PROGRAM_UUID":"string", 2023-08-07 14:27:36 "ACCOUNT_PROGRAM_NAME":"string", 2023-08-07 14:27:36 "ACCOUNT_DISTRIBUTOR_UUID":"string", 2023-08-07 14:27:36 "ACCOUNT_DISTRIBUTOR_NAME":"string", 2023-08-07 14:27:36 "ACCOUNT_COMPANY_ID":"string", 2023-08-07 14:27:36 "ACCOUNT_PERSON_NAME":"string", 2023-08-07 14:27:36 "ACCOUNT_PERSON_LAST_NAME":"string", 2023-08-07 14:27:36 "ACCOUNT_LINKED_REAL_PERSON":"string" 2023-08-07 14:27:36 }, 2023-08-07 14:27:36 "_Card_Deposit_Accounts":[ 2023-08-07 14:27:36 { 2023-08-07 14:27:36 "ACCOUNT_CARD_ID":"22578490", 2023-08-07 14:27:36 "ACCOUNT_CARD_TYPE":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_CREATION_DATE":"2016-09-01T13:37:50+03:00", 2023-08-07 14:27:36 "ACCOUNT_CARD_STATUS_ID":"string", 2023-08-07 14:27:36 "ACCOUNT_MPTS_CARD_ID":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_EXPIRY_DATE_YYMM":"2023-08-01", 2023-08-07 14:27:36 "ACCOUNT_CARD_IDENTIFICATION_CODE":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_PSN":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_IIN_ID":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_LAST_4_ID":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_PROCESSOR":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_ORDER_REF":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_FLOW_STATE":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_CONTACT_LESS":"string", 2023-08-07 14:27:36 "_index":"string", 2023-08-07 14:27:36 "ACCOUNT_CARD_EXPEDITION_FLAG":"string", 2023-08-07 14:27:36 "ONE_TIME_REFILL":false, 2023-08-07 14:27:36 "ACCOUNT_RECHARGED":false 2023-08-07 14:27:36 } 2023-08-07 14:27:36 ], 2023-08-07 14:27:36 "_Bank_Account_Detail_Deposit_Acc":{ 2023-08-07 14:27:36 "BANK_ACCOUNT_NUMBER":"string", 2023-08-07 14:27:36 "BIC_CODE":"string", 2023-08-07 14:27:36 "BANK_ACCOUNT_NAME":"string", 2023-08-07 14:27:36 "IBAN_VERIFIED":"string" 2023-08-07 14:27:36 }, 2023-08-07 14:27:36 "_Deposit_MptsInfo":{ 2023-08-07 14:27:36 "DEPOSIT_ACCOUNT_ID":"string", 2023-08-07 14:27:36 "DEPOSIT_CLIENT_ID":"string" 2023-08-07 14:27:36 }, 2023-08-07 14:27:36 "_Deposit_BomusInfo":{ 2023-08-07 14:27:36 "DEPOSIT_BOMUS_ID":"string" 2023-08-07 14:27:36 } 2023-08-07 14:27:36 } 2023-08-07 14:27:36 ]

outofcoffee commented 1 year ago

Thanks @medaoutir. Using your config from your first comment, the second example is returned:

$ curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
    "filterCriteria": [
        {
            "field": "_Card_Deposit_Accounts.ACCOUNT_CARD_ID",
            "operator": "EQUALS",
            "value": "22578492",
            "secondValue": null,
            "values": null
        }
    ],
    "sortingCriteria": null }'  \
'http://localhost:8080/deposits:search?detailsLevel=FULL'

Note: I had to remove the extra { and } around the JSON payload.

Log:

13:46:42 DEBUG i.g.i.h.AbstractResourceMatcher - Matched resource config for POST http://localhost:8080/deposits:search?detailsLevel=FULL
13:46:42 DEBUG i.g.i.p.o.OpenApiPluginImpl - Setting content type [application/json] from specification for POST http://localhost:8080/deposits:search?detailsLevel=FULL
13:46:42 DEBUG i.g.i.p.o.s.ExampleServiceImpl - Exact example selected: accountExtendedCreatedWhenBlocking
13:46:42 INFO  i.g.i.p.o.s.ResponseTransmissionServiceImpl - Serving mock example for POST http://localhost:8080/deposits:search?detailsLevel=FULL with status code 201 (response body 2648 bytes)

What's the engine-output when you run imposter --version?

medaoutir commented 1 year ago

Hi @outofcoffee { "imposter-cli": "0.28.0", "imposter-engine": "none" } when running:

docker exec -it ais-mock-server-mambu imposter --version

outofcoffee commented 1 year ago

Thanks @medaoutir.

The logging suggests the following match behaviour for the accountExtendedCreatedWhenBlocking resource:

I'm not sure why the path isn't matching your request - the resource has the path /deposits:search whilst the HTTP request is /api/deposits:search 🤔 - have you set a basePath in the config by any chance?

medaoutir commented 1 year ago

Thanks a lot @outofcoffee, Now It's worked as expected; I have updated the config file as below by setting the basePath to "/api":

plugin: openapi
specFile: swagger_accounts.yaml
isPickFirstIfNoneMatch: false
basePath: /api

resources:
  - path: "/deposits:search"
    method: POST
    queryParams:
      detailsLevel: FULL
    requestHeaders:
      Content-Type: application/json
    requestBody:
      allOf:
        - jsonPath: $.filterCriteria[0].field
          value: _Card_Deposit_Accounts.ACCOUNT_CARD_ID
        - jsonPath: $.filterCriteria[0].operator
          value: EQUALS
        - jsonPath: $.filterCriteria[0].value
          value: 22578490
    response:
      exampleName: accountExtendedCreated

  - path: "/deposits:search"
    method: POST
    queryParams:
      detailsLevel: FULL
    requestBody:
      allOf:
        - jsonPath: $.filterCriteria[0].field
          value: _Card_Deposit_Accounts.ACCOUNT_CARD_ID
        - jsonPath: $.filterCriteria[0].operator
          value: EQUALS
        - jsonPath: $.filterCriteria[0].value
          value: 33689503
    response:
      exampleName: accountExtendedCreatedWhenBlocking

Thanks again 👍 I will close the issue.

outofcoffee commented 1 year ago

Thank you very much for the detailed report! We will need to update the docs to recommend that the basePath should be aligned in the OpenAPI plugin.