Skip to content

Commit

Permalink
Generate setters for readonly properties in server code (OpenAPITools…
Browse files Browse the repository at this point in the history
…#1582)

* generate setters for readonly properties in server code

* rollback DefaultGenerator change and remove isReadOnly tags from jaxrs server template

* updating petstore

* more petstore updates
  • Loading branch information
tsiq-karold authored and wing328 committed Mar 31, 2019
1 parent 18b5002 commit 822234d
Show file tree
Hide file tree
Showing 32 changed files with 284 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{/isContainer}}
{{#isContainer}}
{{#mostInnerItems}}
{{>enumClass}}
{{>enumClass}}
{{/mostInnerItems}}
{{/isContainer}}
{{/isEnum}}
Expand All @@ -30,7 +30,6 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali

{{/vars}}
{{#vars}}
{{^isReadOnly}}
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
return this;
Expand Down Expand Up @@ -60,7 +59,6 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
}
{{/isMapContainer}}

{{/isReadOnly}}
/**
{{#description}}
* {{description}}
Expand All @@ -87,12 +85,10 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
{{^isReadOnly}}

public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
{{/isReadOnly}}

{{/vars}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static ArrayEnumEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("array_enum")
private List<ArrayEnumEnum> arrayEnum = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public class HasOnlyReadOnly implements Serializable {
@JsonProperty("foo")
private String foo;

public HasOnlyReadOnly bar(String bar) {
this.bar = bar;
return this;
}

/**
* Get bar
* @return bar
Expand All @@ -44,6 +49,15 @@ public String getBar() {
return bar;
}

public void setBar(String bar) {
this.bar = bar;
}

public HasOnlyReadOnly foo(String foo) {
this.foo = foo;
return this;
}

/**
* Get foo
* @return foo
Expand All @@ -55,6 +69,10 @@ public String getFoo() {
return foo;
}

public void setFoo(String foo) {
this.foo = foo;
}


@Override
public boolean equals(java.lang.Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static InnerEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("map_of_enum_string")
private Map<String, InnerEnum> mapOfEnumString = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public void setName(Integer name) {
this.name = name;
}

public Name snakeCase(Integer snakeCase) {
this.snakeCase = snakeCase;
return this;
}

/**
* Get snakeCase
* @return snakeCase
Expand All @@ -71,6 +76,10 @@ public Integer getSnakeCase() {
return snakeCase;
}

public void setSnakeCase(Integer snakeCase) {
this.snakeCase = snakeCase;
}

public Name property(String property) {
this.property = property;
return this;
Expand All @@ -91,6 +100,11 @@ public void setProperty(String property) {
this.property = property;
}

public Name _123number(Integer _123number) {
this._123number = _123number;
return this;
}

/**
* Get _123number
* @return _123number
Expand All @@ -102,6 +116,10 @@ public Integer get123number() {
return _123number;
}

public void set123number(Integer _123number) {
this._123number = _123number;
}


@Override
public boolean equals(java.lang.Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public class ReadOnlyFirst implements Serializable {
@JsonProperty("baz")
private String baz;

public ReadOnlyFirst bar(String bar) {
this.bar = bar;
return this;
}

/**
* Get bar
* @return bar
Expand All @@ -44,6 +49,10 @@ public String getBar() {
return bar;
}

public void setBar(String bar) {
this.bar = bar;
}

public ReadOnlyFirst baz(String baz) {
this.baz = baz;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static ArrayEnumEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("array_enum")
private List<ArrayEnumEnum> arrayEnum = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class HasOnlyReadOnly {
@JsonProperty("foo")
private String foo;

public HasOnlyReadOnly bar(String bar) {
this.bar = bar;
return this;
}

/**
* Get bar
* @return bar
Expand All @@ -43,6 +48,15 @@ public String getBar() {
return bar;
}

public void setBar(String bar) {
this.bar = bar;
}

public HasOnlyReadOnly foo(String foo) {
this.foo = foo;
return this;
}

/**
* Get foo
* @return foo
Expand All @@ -54,6 +68,10 @@ public String getFoo() {
return foo;
}

public void setFoo(String foo) {
this.foo = foo;
}


@Override
public boolean equals(java.lang.Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static EnumFormStringArrayEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("enum_form_string_array")
private List<EnumFormStringArrayEnum> enumFormStringArray = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static InnerEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("map_of_enum_string")
private Map<String, InnerEnum> mapOfEnumString = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public void setName(Integer name) {
this.name = name;
}

public Name snakeCase(Integer snakeCase) {
this.snakeCase = snakeCase;
return this;
}

/**
* Get snakeCase
* @return snakeCase
Expand All @@ -70,6 +75,10 @@ public Integer getSnakeCase() {
return snakeCase;
}

public void setSnakeCase(Integer snakeCase) {
this.snakeCase = snakeCase;
}

public Name property(String property) {
this.property = property;
return this;
Expand All @@ -90,6 +99,11 @@ public void setProperty(String property) {
this.property = property;
}

public Name _123number(Integer _123number) {
this._123number = _123number;
return this;
}

/**
* Get _123number
* @return _123number
Expand All @@ -101,6 +115,10 @@ public Integer get123number() {
return _123number;
}

public void set123number(Integer _123number) {
this._123number = _123number;
}


@Override
public boolean equals(java.lang.Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class ReadOnlyFirst {
@JsonProperty("baz")
private String baz;

public ReadOnlyFirst bar(String bar) {
this.bar = bar;
return this;
}

/**
* Get bar
* @return bar
Expand All @@ -43,6 +48,10 @@ public String getBar() {
return bar;
}

public void setBar(String bar) {
this.bar = bar;
}

public ReadOnlyFirst baz(String baz) {
this.baz = baz;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static ArrayEnumEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("array_enum")
private List<ArrayEnumEnum> arrayEnum = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class HasOnlyReadOnly {
@JsonProperty("foo")
private String foo;

public HasOnlyReadOnly bar(String bar) {
this.bar = bar;
return this;
}

/**
* Get bar
* @return bar
Expand All @@ -43,6 +48,15 @@ public String getBar() {
return bar;
}

public void setBar(String bar) {
this.bar = bar;
}

public HasOnlyReadOnly foo(String foo) {
this.foo = foo;
return this;
}

/**
* Get foo
* @return foo
Expand All @@ -54,6 +68,10 @@ public String getFoo() {
return foo;
}

public void setFoo(String foo) {
this.foo = foo;
}


@Override
public boolean equals(java.lang.Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static InnerEnum fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

@JsonProperty("map_of_enum_string")
private Map<String, InnerEnum> mapOfEnumString = null;

Expand Down
Loading

0 comments on commit 822234d

Please sign in to comment.