znsio / specmatic

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

proxy server creates only the json file and not the yaml files which can not be stubbbed #1365

Open GagandeepSharma060 opened 1 month ago

GagandeepSharma060 commented 1 month ago

I have two services

  1. UI
  2. API

I am using the specmatic proxy server on the API and then pointing my UI to the proxy. Now I manually go to some pages on my UI do some CRUDs, when I press CNTR+C, only the JSON files are created and the yaml contract is not created. So in this case the json files are of no use to me as they can not be stubbed without a contract

Please help here THanks

harikrishnan83 commented 1 month ago

hello @GagandeepSharma060, thanks for reporting the issue. We will take a look

pranavgawri commented 1 month ago

Hi @GagandeepSharma060 ,

We tried to replicate the scenario where only JSON files are created without the YAML contract, but in our testing environment, both the examples and spec files are being generated correctly.

To help us investigate this better, could you share:

  1. The specifications for your UI and API services
  2. The proxy server configuration you're using
  3. Any error messages you might be seeing in the logs

I noticed you're using CTRL+C to generate the spec and examples. While this works, I wanted to share a more convenient approach that doesn't require stopping the proxy server:

You can trigger the dump operation by sending a POST request to:

/_specmatic/proxy/dump

This endpoint is especially useful when:

For more details about proxy configuration and contract generation, please refer to our documentation: https://specmatic.io/documentation/authoring_contracts.html#dumping-the-contracts-and-examples-using-the-dump-endpoint

Thanks, Pranav

GagandeepSharma060 commented 1 month ago

Hi @pranavgawri ,Apologies but I cannot provide u the code but can help u with a little more details

The API that i am trying to record is being fetched by the UI from the configuration file in the sources

image

.

SO the UI picks the API base url from configuration file in the network tab and makes request as per my activities on UI

In this scenario whatever I do is recorded as stubs but no file is created. Can u check the reason.

Thanks for the response

pranavgawri commented 4 weeks ago

Hi @GagandeepSharma060,

Thanks for sharing the additional context. I've tested the contract generation following our standard documentation (https://specmatic.io/documentation/authoring_contracts.html#generating-api-specifications) and can confirm it's working as expected, generating both OAS specification and Examples (json) successfully.

While testing, I did discover an interesting edge case, where I was able to replicate the scenario you reported. We're currently investigating the same. I'll update you once we have more findings to share.

Thanks, Pranav

GagandeepSharma060 commented 4 weeks ago

Thanks @pranavgawri