Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
stubby4node comma separated query string implementation issue

I have a URL (GET REQUEST) of the following pattern

  • ^/testpath/1/test?pathid=1
  • ^/testpath/1/test?pathid=1,2
  • ^/testpath/1/test?pathid=1,2,5

where pathid query string parameters are comma separated

I have the following stubby mappings to match these url patterns

- request:
    url: ^/testpath/(.*)/test
    query:
      pathid: '1'
    method: GET
  response:
    headers:
      Content-Type: application/json
    status: 200
    file: response/path-1.json

- request:
    url: ^/testpath/(.*)/test
    query:
      pathid: '1,2'
    method: GET
  response:
    headers:
      Content-Type: application/json
    status: 200
    file: response/path-2.json

- request:
    url: ^/testpath/(.*)/test
    query:
      pathid: '1,2,5'
    method: GET
  response:
    headers:
      Content-Type: application/json
    status: 200
    file: response/path-3.json

but I can't get this URL mapping to properly deliver different payloads based on different parameter combinations.

  • 1 -> payload1
  • 1,2 -> payload2
  • 1,2,5 -> payload3

how can this be done?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

@Sanath, short answer - yes, stubby4j matches on different stubbed query parameters combinations.

Few questions:

  1. What version of stubby4j are you running?
  2. Also, are you running stubby4j as a standalone JAR or as one of the pre-built stubby4j Docker containers?

I wrote a test to validate the YAML configuration you provided in your question: https://github.com/azagniotov/stubby4j/pull/434/files (do note, I did change the url a little, but it is still a regex similar to your posted YAML).

The requests that test makes do match the stubs. (I did try without $ and with a $, like @code suggested). In addition, I also tested with cURL against a running standalone JAR:

curl -X GET  http://localhost:8882/stackoverflow/70417269/1/test?pathid=1,2,5

and

curl -X GET  http://localhost:8882/stackoverflow/70417269/1/test?pathid=1,2

Again, I got the expected responses from the server.

If the above does not help you, please feel free to raise a bug report https://github.com/azagniotov/stubby4j/issues/new/choose

about 4 years ago · Juan Pablo Isaza Denunciar

0

The trick here is to change the order of request/response mappings in the yaml file.

- request:
    url: ^/testpath/(.*)/test
    query:
      **pathid: '1,2,5'**
    method: GET
  response:
    headers:
      Content-Type: application/json
    status: 200
    file: response/path-3.json

- request:
    url: ^/testpath/(.*)/test
    query:
      **pathid: '1,2'**
    method: GET
  response:
    headers:
      Content-Type: application/json
    status: 200
    file: response/path-2.json

- request:
    url: ^/testpath/(.*)/test
    query:
      **pathid: '1'**
    method: GET
  response:
    headers:
      Content-Type: application/json
    status: 200
    file: response/path-1.json

note the path ids added in the descending order, so that more deeper matches will be executed first.

This way I was able to achieve this following requirement, of passing different path ids separated by a comma

  • 1 -> payload1
  • 1,2 -> payload2
  • 1,2,5 -> payload3
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda