What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Glue Api Versioning: I am trying to implement Versioning for CustomRestAPI. I have created Two ver
Glue Api Versioning:
I am trying to implement Versioning for CustomRestAPI. I have created Two versions version 2 and version 3 TestimonialResourceRouteVersion2Plugin, TestimonialResourceRouteVersion3Plugin
and added ResourceVersionableInterface
in implement. it has method getVersion function per file as well.
Version2 File: public function getVersion(): RestVersionTransfer { return (new RestVersionTransfer()) ->setMajor(2) ->setMinor(0); } Version3 File: public function getVersion(): RestVersionTransfer { return (new RestVersionTransfer()) ->setMajor(3) ->setMinor(0); }
I have added in GlueDependencyProvider file as well. Issue is when I try to request to the data, it always returning Version3 data. I passed version:2.0 in header parameter but it't not retrieving version 2.0 data.
If I pass wrong version number, 4.0 as header param, it should return 404 as well but in my case it's returning version 3.0 data . Seems something is missing.
Any help would be appreciated.
Comments
-
Hi @U035GSLDLVD can you please check some of the configurations:
- There are two configs we introduced recently that will allow passing the version in the URL instead of the header:
Config below should be false for header:
\Spryker\Glue\GlueApplication\GlueApplicationConfig::getPathVersionResolving
Config below is not used if the first config is false:
\Spryker\Glue\GlueApplication\GlueApplicationConfig::getPathVersionPrefix
- Please check that you are passing the version correct in the header
*Content*-*Type*: application/vnd.api+json; version=2.0
.
If you set it:version:2.0
as you have mentioned, it will not work.
Also please note that the original plugin (version 1.0) will also need to implement the versionable interface since there will be no way to access it (passing no version in the header will always resolve to the latest version - 3.0)
0 - There are two configs we introduced recently that will allow passing the version in the URL instead of the header:
-
@U033AS56258 Thanks for the help! I looked into this. Yes both functions exist in below file with following return type.
\Spryker\Glue\GlueApplication\GlueApplicationConfig::getPathVersionResolving => return False
\Spryker\Glue\GlueApplication\GlueApplicationConfig::getPathVersionPrefix => return ''
I have not modified these functions in project specific file:
Pyz\Glue\GlueApplication\GlueApplicationConfig
Yes, I am passing version correctly. I am using Postman to request the different version but it is always returning the latest version data.
0 -
Did you mean I need to implement default api as Version 1? then only rest of the versions will work?
0 -
I got some feedback internally that version 2 vs version 3 should be working as it is, however, will be following up again.
0 -
I got a confirmation that version 2 and 3 should work without implementing versionable interface for version 1 which is the original plugin
0 -
Thanks Anila! Appreciate your help! will share what I tried so far.
0 -
I checked it locally and it seems to be a formatting issue (a missing space), and it seems to work as expected Content-Type is:
application/vnd.api+json; version=3.0
Response: this is third
application/vnd.api+json; version=2.0
Response: this is second
application/vnd.api+json; version=4.0
Response:
{ "errors": [ { "status": 404, "detail": "Not Found" } ] }
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random