-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve support for externalizing strings in generated openapi. Fixes #…
- Loading branch information
1 parent
460d543
commit 1ca8bc5
Showing
5 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...i-starter-common/src/main/java/org/springdoc/core/conditions/SpecPropertiesCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.springdoc.core.conditions; | ||
|
||
/** | ||
* @author bnasslahsen | ||
*/ | ||
|
||
import java.util.Set; | ||
|
||
import org.springdoc.core.properties.SpringDocConfigProperties; | ||
import org.springdoc.core.properties.SpringDocConfigProperties.GroupConfig; | ||
|
||
import org.springframework.boot.context.properties.bind.BindResult; | ||
import org.springframework.boot.context.properties.bind.Binder; | ||
import org.springframework.context.annotation.Condition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
|
||
import static org.springdoc.core.utils.Constants.SPRINGDOC_PREFIX; | ||
|
||
/** | ||
* The type Spec properties condition. | ||
* | ||
* @author bnasslahsen | ||
*/ | ||
public class SpecPropertiesCondition implements Condition { | ||
|
||
@Override | ||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
final BindResult<SpringDocConfigProperties> result = Binder.get(context.getEnvironment()) | ||
.bind(SPRINGDOC_PREFIX, SpringDocConfigProperties.class); | ||
if (result.isBound()) { | ||
SpringDocConfigProperties springDocConfigProperties = result.get(); | ||
if (springDocConfigProperties.getOpenApi() != null) | ||
return true; | ||
Set<GroupConfig> groupConfigs = springDocConfigProperties.getGroupConfigs(); | ||
return groupConfigs.stream().anyMatch(config -> config.getOpenApi() != null); | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters