Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sentinel
Commits
6e072fca
Commit
6e072fca
authored
Oct 13, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化日志输出
parent
7dfd61c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
112 deletions
+1
-112
ParameterDataTypeReader.java
...spring/web/readers/parameter/ParameterDataTypeReader.java
+0
-112
logback.xml
src/main/resources/logback.xml
+1
-0
No files found.
src/main/java/springfox/documentation/spring/web/readers/parameter/ParameterDataTypeReader.java
deleted
100644 → 0
View file @
7dfd61c1
/*
*
* Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package
springfox
.
documentation
.
spring
.
web
.
readers
.
parameter
;
import
static
springfox
.
documentation
.
schema
.
Collections
.
collectionElementType
;
import
static
springfox
.
documentation
.
schema
.
Collections
.
isContainerType
;
import
static
springfox
.
documentation
.
schema
.
Maps
.
isMapType
;
import
static
springfox
.
documentation
.
schema
.
ResolvedTypes
.
modelRefFactory
;
import
static
springfox
.
documentation
.
schema
.
Types
.
isBaseType
;
import
static
springfox
.
documentation
.
schema
.
Types
.
typeNameFor
;
import
static
springfox
.
documentation
.
spi
.
schema
.
contexts
.
ModelContext
.
inputParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.fasterxml.classmate.ResolvedType
;
import
com.fasterxml.classmate.TypeResolver
;
import
com.google.common.base.Optional
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.schema.ModelReference
;
import
springfox.documentation.schema.TypeNameExtractor
;
import
springfox.documentation.service.ResolvedMethodParameter
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.schema.contexts.ModelContext
;
import
springfox.documentation.spi.service.ParameterBuilderPlugin
;
import
springfox.documentation.spi.service.contexts.ParameterContext
;
@Component
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
public
class
ParameterDataTypeReader
implements
ParameterBuilderPlugin
{
private
final
TypeNameExtractor
nameExtractor
;
private
final
TypeResolver
resolver
;
@Autowired
public
ParameterDataTypeReader
(
TypeNameExtractor
nameExtractor
,
TypeResolver
resolver
)
{
this
.
nameExtractor
=
nameExtractor
;
this
.
resolver
=
resolver
;
}
@Override
public
boolean
supports
(
DocumentationType
delimiter
)
{
return
true
;
}
@Override
public
void
apply
(
ParameterContext
context
)
{
ResolvedMethodParameter
methodParameter
=
context
.
resolvedMethodParameter
();
ResolvedType
parameterType
=
methodParameter
.
getParameterType
();
parameterType
=
context
.
alternateFor
(
parameterType
);
ModelReference
modelRef
=
null
;
if
(
methodParameter
.
hasParameterAnnotation
(
PathVariable
.
class
)
&&
treatAsAString
(
parameterType
))
{
parameterType
=
resolver
.
resolve
(
String
.
class
);
modelRef
=
new
ModelRef
(
"string"
);
}
else
if
(
methodParameter
.
hasParameterAnnotation
(
RequestParam
.
class
)
&&
isMapType
(
parameterType
))
{
modelRef
=
new
ModelRef
(
""
,
new
ModelRef
(
"string"
),
true
);
}
else
if
(
methodParameter
.
hasParameterAnnotation
(
RequestParam
.
class
)
&&
treatRequestParamAsString
(
parameterType
))
{
parameterType
=
resolver
.
resolve
(
String
.
class
);
modelRef
=
new
ModelRef
(
"string"
);
}
if
(!
methodParameter
.
hasParameterAnnotations
())
{
Class
<?>
t
=
parameterType
.
getErasedType
();
String
typeName
=
typeNameFor
(
t
);
if
(
isBaseType
(
typeName
))
{
modelRef
=
new
ModelRef
(
typeName
);
}
else
{
//LOG.warn("Trying to infer dataType {}", parameterType);
}
}
ModelContext
modelContext
=
inputParam
(
parameterType
,
context
.
getDocumentationType
(),
context
.
getAlternateTypeProvider
(),
context
.
getGenericNamingStrategy
(),
context
.
getIgnorableParameterTypes
());
context
.
parameterBuilder
()
.
type
(
parameterType
)
.
modelRef
(
Optional
.
fromNullable
(
modelRef
)
.
or
(
modelRefFactory
(
modelContext
,
nameExtractor
).
apply
(
parameterType
)));
}
private
boolean
treatRequestParamAsString
(
ResolvedType
parameterType
)
{
return
treatAsAString
(
parameterType
)
&&
!
isContainerType
(
parameterType
)
||
(
isContainerType
(
parameterType
)
&&
treatAsAString
(
collectionElementType
(
parameterType
)));
}
private
boolean
treatAsAString
(
ResolvedType
parameterType
)
{
return
!(
isBaseType
(
typeNameFor
(
parameterType
.
getErasedType
()))
||
parameterType
.
getErasedType
().
isEnum
());
}
}
src/main/resources/logback.xml
View file @
6e072fca
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<logger
name=
"springfox"
level=
"ERROR"
/>
<logger
name=
"com.egolm"
level=
"DEBUG"
/>
<logger
name=
"com.egolm"
level=
"DEBUG"
/>
<appender
name=
"siftingAppender"
class=
"ch.qos.logback.classic.sift.SiftingAppender"
>
<appender
name=
"siftingAppender"
class=
"ch.qos.logback.classic.sift.SiftingAppender"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment