postman-app-support
postman-app-support copied to clipboard
Sync with schema is not updating the mock server
Is there an existing issue for this?
- [X] I have searched the tracker for existing similar issues and I know that duplicates will be closed
Describe the Issue
I am using Postman to coordinate the development of my APIs with another groups, including the usage of a mock server.
The issue is that there I could not find a way to synchronize changes made to the my API definition to collection (and mocks), so far the only option that I found is to recreate both collections and mock server, but this will change the URL and will impact the other team.
I tried to use the approach listed in #8697, with the API https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/:relationType/:entityId/syncWithSchema, I got a "success: true" response but a call to the newly created endpoint is not working.
PS: I am creating as a bug because I believe that the expected approach is to update it, if this is not the expected approach I can open a feature request.
Steps To Reproduce
- Create an API definition
- Generate a collection from the API
- Generate a mock based in the collection
- Create a new endpoint in the same version of the API
- Call the endpoint "https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/mock/:entityId/syncWithSchema"
- Call the new endpoint
Screenshots or Videos
No response
Operating System
Windows
Postman Version
v10
Postman Platform
Postman Web
User Account Type
Signed In User
Additional Context?
No response
@peruzzof thanks for raising this, we are working on a feature that will let you update a collection as and when your schema gets updated. I wanted to understand one thing here, are you creating a Mock by using 'copy to collections' functionality?
Currently I am trying to find an automated way to do it, so everything was created using the APIs:
- Create the API using POST to https://api.getpostman.com/apis?workspace=$workspaceid
- Create the OpenAPI using POST to "https://api.getpostman.com/apis/$apiid/versions/$versionid/schemas (or PUT to update)
- Create the collection using POST to https://api.getpostman.com/apis/$apiid/versions/$versionid/schemas/$schemaid/collections?workspace=$workspaceid (specifying only the name of the API)
- Create the mock using POST to https://api.getpostman.com/mocks?workspace=$workspaceid
Then I updated the API definition using the interface (just to avoid some calls). At this moment I am not sure if I had to add the relation between API and mock (using the API https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/relations) or if I was able to call only the mentioned API (https://api.getpostman.com/apis/{{apiId}}/versions/{{apiVersionId}}/:relationType/:entityId/syncWithSchema). Anyway I got a success return, but the Mock wasnt updated.
@peruzzof thanks for raising this, we are working on a feature that will let you update a collection as and when your schema gets updated. I wanted to understand one thing here, are you creating a Mock by using 'copy to collections' functionality?
@shashankawasthi88 is this the correct way to create mocks from definition now? 1.- APIs Menu -> Create definition 2.- APIs Menu ->Add Collection --> Generate From Definition 3.- APIs Menu ->Copy to Collections 4.- Collections Menu -> Mock Collection
Sync collections from the definition enforce the concept of single source of truth, i hope you can fix this
Best regards
Is there any update on this? I'm running into this issue as well.
Why does a collection generated from an OAS, under the APIs tab, not have the ability to create a mock server? As far as I can tell, the collection that gets copied to the collections tab is not in sync with the collection under the APIs tab.
@dsigmund89 you are correct. The collection copied to the collections tab is not in sync. We are working on making the mocks available for collection under API tab itself. Ill update this thread once we have an update. I would like to know, however, at what stage in your API development lifecycle do you use mocks? If you can walk up through some of your usecases, it will be helpful for us designing better solution.
Currently we're using SwaggerHub UI to manage our OAS documents, including the mock urls they provide. We're using those mock calls before we start code development. We also use postman to generate collections for our clients/testers. But to consolidate, we'd like to move everything over to Postman to keep everything in sync. I imagine a flow looking similar to the following:
- Create OAS
- Generate Collection from OAS
- Publish API with OAS and collection for end users for testing.
- Generate Mock URLs per published version. This would allow us to have multiple versions running at the same time. I know I can technically do this now if I manually copied over the the collection to the collections tab. But that runs the issue of it getting out of sync with the OAS.
@shashankawasthi88 the use case is the same for me, based on API First / Design First aproach:
- Create OAS
- Generate Documentation from OAS
- Generate mock from OAS
- Mock generated from OAS used for testing and for consumers
In previous versions of postman we can create in the API menu:
- Mock Collections from definition
- Documentation Collections from definition
- Testing Collections from definition
In newer versions seems that we can do that anymore (i'm using Version 10.14.4 of postman for windows)
@dsigmund89 thanks for pushing this issue
@dsigmund89 @dgonzalezc thanks for explaining the workflow end to end. Your workflow can actually be completed in the product in a better and intended way. Once you publish a version in Postman, you can create a Fork of the published collection in your workspace. Now this fork can be updated by pulling changes every time a new version is published. This way the mock is updated, with just the action of pulling changes. Read last section of my blog to understand how the forks can be created, and this link to understand how to pull changes when a new version is published. If needed we can get onto a call and I can walk you through the process. You can pick a time using this link
@shashankawasthi88 Thank's for the quick response! Yes I can see how forking the collection would be a solution but from an end user/tester standpoint. Having 2 collections that are supposed to be the same thing, but in different locations, could be confusing for them. I'll explore that as an option with my team. I just think it would be easier to have the 1 collection under the API tab as the source of truth. And use it for both mocking and monitoring without having to create fork's of the collections.
But I am curious why is a collection under the API tab limited compared to a collection under the Collections tab? Should they not have the same functionality?
API Tab
Collections Tab
I'm on the latest postman v10.14.5
@dsigmund89 Yes we agree that the mock experience needs to be built in the API experience itself and we are working towards it. Ill revert on the same thread as we make progress on the same. We are actively tracking it.
On your question around functionality being different/ limited in the API collections - the API collections are more tuned towards API producer experience. Not all options present in the Collections tab directly apply to the API collections. Having said that, we are implementing features in API collections as we validate them one by one.