-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added generator for microprofile openapi schema #96
Added attribute : 'package-helper-microprofile' To daogen-config Added attribute : 'exampleData' To field And relevant implementation
- Loading branch information
Showing
52 changed files
with
502 additions
and
595 deletions.
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
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
58 changes: 58 additions & 0 deletions
58
...se/src/main/java/org/fugerit/java/daogen/base/gen/MicroProfileSchemaWrapperGenerator.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,58 @@ | ||
package org.fugerit.java.daogen.base.gen; | ||
|
||
import org.fugerit.java.core.cfg.ConfigException; | ||
import org.fugerit.java.core.db.dao.DAOException; | ||
import org.fugerit.java.core.lang.helpers.StringUtils; | ||
import org.fugerit.java.daogen.base.config.*; | ||
import org.fugerit.java.daogen.base.gen.util.WrapperUtils; | ||
|
||
import java.io.IOException; | ||
|
||
public class MicroProfileSchemaWrapperGenerator extends DaogenBasicGenerator { | ||
|
||
public static final String KEY = "MicroProfileSchemaWrapperGenerator"; | ||
|
||
@Override | ||
public String getKey() { | ||
return KEY; | ||
} | ||
|
||
public void init( DaogenCatalogConfig daogenConfig, DaogenCatalogEntity entity ) throws ConfigException { | ||
super.init( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_SRC_MAIN_JAVA ), | ||
fullObjectName( daogenConfig.getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER_MICROPROFILE ), DaogenCatalogConstants.mpSchemaName( entity ) ), | ||
STYLE_CLASS, daogenConfig, entity ); | ||
this.getImportList().add( "org.eclipse.microprofile.openapi.annotations.media.Schema" ); | ||
WrapperUtils.init( daogenConfig, entity, this ); | ||
new DaogenBasicDecorator() { | ||
@Override | ||
public void addBeforeClass() throws DAOException { | ||
super.addBeforeClass(); | ||
if ( StringUtils.isNotEmpty( entity.getComments() ) ) { | ||
this.accessGenerator().println( String.format( "@Schema( description = \"%s\")" , entity.getComments() ) ); | ||
} | ||
} | ||
}.init( this ); | ||
} | ||
|
||
@Override | ||
public String getEntityWrapperName() { | ||
return DaogenCatalogConstants.mpSchemaName( this.getCurrentEntity() ); | ||
} | ||
|
||
@Override | ||
public void generateDaogenBody() throws IOException { | ||
WrapperUtils.generateBody( this, f -> { | ||
if (StringUtils.isNotEmpty( f.getComments() ) ) { | ||
String base = "@Schema( description = \"%s\" %s)"; | ||
String extra = ""; | ||
if ( StringUtils.isNotEmpty( f.getExampleData() ) ) { | ||
extra = String.format( ", example =\"%s\"", f.getExampleData() ); | ||
} | ||
return String.format( base , f.getComments(), extra ); | ||
} else { | ||
return null; | ||
} | ||
} ); | ||
} | ||
|
||
} |
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
Oops, something went wrong.