znsio / specmatic

Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.
https://specmatic.io
MIT License
283 stars 52 forks source link

Support `baseURL` for Stub Server #1431

Open harikrishnan83 opened 1 week ago

harikrishnan83 commented 1 week ago

Is your feature request related to a problem? Please describe. Many a times, the API path needs to be prefixed with additional path segments. Example: /products needs to be prefixed with /api/store/.

Describe the solution you'd like Support either both or at least one capability.

Additional context Creating this on behalf of @twinkle12b as a follow-up to issue #1425

twinkle12b commented 1 week ago

Hello thanks for opening this request, can you help me resolve the issue of how can I also do this for my stub server as it is also not able to detect the server url path, like i can set system property for testbaseurl base path for contract as test. How can i do this for stub server basepath

twinkle12b commented 1 week ago

Hey @harikrishnan83 @samyakOO7 any updates on the question???

harikrishnan83 commented 1 week ago

hello @twinkle12b, thanks for following up on this.

We are already working on option 1 "Support baseURL similar to testBaseURL for stub server" mentioned above. And should be available shortly.

Meanwhile on option 2 "Pick it up from servers section", the servers section in OpenAPI 3.0.x, as you may be aware, can have multiple servers.

servers:
  - url: https://api.production.example.com/v1
    description: Production server
  - url: https://api.staging.example.com/v1
    description: Staging server
  - url: http://localhost:8080/v1
    description: Local development server

So to pick one of them we plan to use description field as the identifier for the URL. So the syntax may look something like specmatic test --server "Local development server" or specmatic virtualize/stub --server "Local development server". Any thoughts on this?

Thanks.

cc @samyakOO7

twinkle12b commented 1 week ago

Hi @samyakOO7 how can i do this programmatically like via some system property, as i running test class and not command line

harikrishnan83 commented 1 week ago

hello @twinkle12b, we will update our documentation and share the link with you as soon as this is available shortly. Thanks.