Skip to content

Instantly share code, notes, and snippets.

@Test
public void fieldsUseLowerCaseCamel() {
String schema = readFileToString(new File(getClass().getResource("/schema.json").getPath()), Charset.forName("UTF-8"));
Swagger swagger = new SwaggerParser().parse(schema);
for (Map.Entry<String, Model> entry : swagger.getDefinitions().entrySet()) {
if (entry.getValue().getProperties() == null) {
continue;
}
for (String fieldName : entry.getValue().getProperties().keySet()) {
{{#vendorExtensions.x-enum-definition}}{{.}}{{/vendorExtensions.x-enum-definition}}
{{^vendorExtensions.x-enum-definition}}{{{dataType}}}{{/vendorExtensions.x-enum-definition}}
{
"name": "account_type",
"in": "query",
"required": false,
"type": "string",
"enum": [
"PERSONAL",
"COLLEGE_SAVING"
],
"x-enum-definition": "AccountType"
public class V1Api {
@Inject V1ApiService delegate;
@GET
@Path("/v1/account")
public AccountInfo getAccountInfo(@ApiParam(required=true) @QueryParam("account_id") String accountId, @ApiParam(required=false) @QueryParam("account_type") String accountType) {
return delegate.getAccountInfo(accountId);
}
{
"name": "account_type",
"in": "query",
"required": false,
"type": "string",
"enum": [
"PERSONAL",
"COLLEGE_SAVING"
]
}
public enum {{{classname}}} {
{{#allowableValues}}
{{#values}}{{.}},{{/values}}
{{/allowableValues}}
@JsonEnumDefaultValue
ENUM_DEFAULT_VALUE
}
{{#model}}
public static class Builder {
{{#vars}}
private {{{datatypeWithEnum}}} {{name}};
{{/vars}}
{{#vars}}
public Builder {{name}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
return this;
public static class Builder {
private AccountType accountType;
public Builder accountType(AccountType accountType) {
this.accountType = accountType;
return this;
}
public AccountInfo build() {
public class V1Api {
@Inject V1ApiService delegate;
@GET
@Path("/v1/account")
public AccountInfo getAccountInfo(@ApiParam(required=true) @QueryParam("account_id") String accountId) {
assertNotNull(accountId); // null check generated for all required parameters
return delegate.getAccountInfo(accountId);
}
public class V1Api {
@Inject V1ApiService delegate;
@GET
@Path("/v1/account")
public AccountInfo getAccountInfo(@ApiParam(required=true) @QueryParam("account_id") String accountId) {
return delegate.getAccountInfo(accountId);
}