Skip to content

Commit

Permalink
Fixed incorrect code generated with 'additionalProperties:true'
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Durnoga committed Aug 13, 2018
1 parent 3e0253d commit b5756a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MainApiVerticle extends AbstractVerticle {

@Override
public void start(Future<Void> startFuture) throws Exception {
LOGGER.info("Starting MainApiVerticle");
LOGGER.info("Starting MainApiVerticle...");
Json.mapper.registerModule(new JavaTimeModule());
FileSystem vertxFileSystem = vertx.fileSystem();
vertxFileSystem.readFile("swagger.json", readFile -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{#serializableModel}} implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}}

{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}

{{>enumClass}}{{/items}}{{/items.isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}

public {{classname}} () {
}

{{#vars}}{{#-first}}
public {{classname}} ({{#vars}}{{{datatypeWithEnum}}} {{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}) {
{{#vars}}
this.{{name}} = {{name}};
{{/vars}}
}

{{/-first}}{{/vars}}
{{#vars}}
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
@JsonProperty("{{baseName}}")
Expand All @@ -28,6 +27,17 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
return this;
}

{{#isMapContainer}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;
}
{{/isMapContainer}}
{{/vars}}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ private static void configureRoute(Route route, String serviceId, Operation oper
}
} catch (Throwable t) {
vertxLogger.error("Internal Server Error", t);
response.setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code());
response.end();
if (!response.ended()) {
response.setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code());
response.end();
}
}
});
} catch (Exception e) {
Expand Down

0 comments on commit b5756a6

Please sign in to comment.