解决swagger文档接口404的问题

问题描述:swagger文件测试接口404排查和解决,遇到这样的问题如何解决和排查我们来看。

接口测试:

这个时候怎么解决呢?看日志

1,分析问题的根源,如果是加了权限控制要放行swagger 地址,显示我们这个不是swagger没有放行,那就是鉴权出了问题。

日志鉴权貌似也没有问题?那是什么原因导致的呢?

 

GET http://localhost:11031/{GET%20/ydpw/collection/list}

这个地址其实很多会说是多了一个空格其实不是的,正常会转码。

那么到底是什么问题?

原因是我们的服务名称和路由的名字都是一样这样不规范,导致地址找不到我们去掉控制器的名称就好了。

 

 代码不规范,不摆烂了,所以代码要规范。。。

/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package cn.citms.portal.cms.controller;

import cn.citms.example.entity.cms.TblDirectoryCollection;
import cn.citms.example.vo.cms.DirectoryCollectionVo;
import cn.citms.portal.cms.service.DirectoryService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

/**
 * 答案选项 控制器
 *
 * @author Blade
 * @since 2022-02-16
 */
@RestController
@AllArgsConstructor
@RequestMapping("/collection")
@Api(value = "目录收藏", tags = "目录收藏")
public class DirectoryCollectionController extends BladeController {

	private DirectoryService directoryService;

	/**
	 * 详情
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "当前用户所有收藏", notes = "当前用户所有收藏")
	public R  detail(DirectoryCollectionVo directoryCollection) {
		List<DirectoryCollectionVo> result = directoryService.list(directoryCollection);
		return R.data(result);

	}



	
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小杨互联网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值