Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GagandeepSharma060 opened this issue Oct 20, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@GagandeepSharma060
Copy link

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
Copy link
Member

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

@harikrishnan83 harikrishnan83 self-assigned this Oct 20, 2024
@pranavgawri
Copy link
Contributor

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:

  • You want to keep the proxy running while capturing more interactions
  • You're running automated UI tests and want to capture contracts at specific points
  • You need to generate contracts multiple times during a testing session

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

@harikrishnan83 harikrishnan83 added the question Further information is requested label Oct 24, 2024
@GagandeepSharma060
Copy link
Author

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
Copy link
Contributor

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

@pranavgawri pranavgawri added bug Something isn't working and removed question Further information is requested labels Oct 25, 2024
@GagandeepSharma060
Copy link
Author

Thanks @pranavgawri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants