Skip to content

Commit

Permalink
Update PrimitiveType.java to allow customClasses (#4192)
Browse files Browse the repository at this point in the history
* Update PrimitiveType.java to allow customClasses

This PR is part of commit 2ecbdb5 
to fix this issue #1445. 
It was fixed in swagger 2.0.6+ but not included in swagger 1.5 branch.

* Update PrimitiveType.java

---------

Co-authored-by: Francesco Tumanischvili <frantuma@yahoo.com>
  • Loading branch information
kenzhang-mark43 and frantuma authored Jan 26, 2024
1 parent 3931b77 commit cb52f5d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,19 @@ private PrimitiveType(Class<?> keyClass, String commonName) {
}

/**
* Adds support for custom mapping of classes to primitive types
* Adds support for custom excluded classes
*
* @return Set of custom classes to primitive type
* @since 1.6.6
* @return Set of custom excluded classes
*/
public static Set<String> customExcludedClasses() {
return customExcludedClasses;
}

/**
* Adds support for custom mapping of classes to primitive types
* Adds support for custom excluded external classes
*
* @return Set of custom classes to primitive type
* @return Set of custom excluded external classes
*/
public static Set<String> customExcludedExternalClasses() {
return customExcludedExternalClasses;
Expand All @@ -277,6 +278,7 @@ public static Set<String> customExcludedExternalClasses() {
/**
* Adds support for custom mapping of classes to primitive types
*
* @since 1.6.13
* @return Map of custom classes to primitive type
*/
public static Map<String, PrimitiveType> customClasses() {
Expand All @@ -295,6 +297,7 @@ public static PrimitiveType fromType(Type type) {
if (custom != null) {
return custom;
}

final PrimitiveType external = EXTERNAL_CLASSES.get(raw.getName());
if (external != null) {
if (!customExcludedExternalClasses().contains(raw.getName())) {
Expand Down

0 comments on commit cb52f5d

Please sign in to comment.