如图所示,在编写api时会涉及到N多版本。
此时除了在route文件夹中新建路由时,还需修改accept中的版本。<分离路由:www.jianshu.com/p/81918383386f>
客户端传了Accept : application/vnd.musikid.vX+json的情况,把X当成请求版本号,否则使用默认的v1
v1版本
v2版本
如果以上你都编写完毕,运行时出现以下情况的话:
此时你需要修改配置文件中API_VERSION的版本号。修改完毕执行php artisan config:cache
“ This version is the default version of your API and is used as a fallback in several circumstances whenever a version is not supplied. This version is also used as a default version for when generating API documentation. ”
此处版本号要填写默认版本号,例如:v1
运行测试成功!