Skip to content

Commit

Permalink
[Java][JavaJaxRS] Respect readOnly/writeOnly attribute markers (#9276)
Browse files Browse the repository at this point in the history
* [Java] [JavaJaxRS] Respect readOnly/writeOnly attribute markers

Generate jackson JsonProperty like following:
- `readOnly` is present in Spec: `@JsonProperty(value = "[name]", access = JsonProperty.Access.READ_ONLY)`
- `writeOnly` is present in Spec: `@JsonProperty(value = "[name]", access = JsonProperty.Access.WRITE_ONLY)`

Edge case: both are present -> Spec is invalid and generator cancels anyway with:
> org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
> | Error count: 1, Warning count: 1
> Errors: 
>	-attribute components.schemas.Example. writeOnly and readOnly are both present

* update samples

Co-authored-by: Michael Kroll <[email protected]>
  • Loading branch information
wing328 and mickroll authored Apr 16, 2021
1 parent 4a63aae commit 515d4a0
Show file tree
Hide file tree
Showing 258 changed files with 876 additions and 876 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{{vendorExtensions.x-extra-annotation}}}
{{/vendorExtensions.x-extra-annotation}}
{{#jackson}}
@JsonProperty("{{baseName}}")
@JsonProperty(value = "{{baseName}}"{{#isReadOnly}}, access = JsonProperty.Access.READ_ONLY{{/isReadOnly}}{{#isWriteOnly}}, access = JsonProperty.Access.WRITE_ONLY{{/isWriteOnly}})
{{/jackson}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AdditionalPropertiesAnyType name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public AdditionalPropertiesArray name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AdditionalPropertiesBoolean name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public AdditionalPropertiesClass putMapStringItem(String key, String mapStringIt
* Get mapString
* @return mapString
**/
@JsonProperty("map_string")
@JsonProperty(value = "map_string")
@ApiModelProperty(value = "")

public Map<String, String> getMapString() {
Expand Down Expand Up @@ -134,7 +134,7 @@ public AdditionalPropertiesClass putMapNumberItem(String key, BigDecimal mapNumb
* Get mapNumber
* @return mapNumber
**/
@JsonProperty("map_number")
@JsonProperty(value = "map_number")
@ApiModelProperty(value = "")
@Valid
public Map<String, BigDecimal> getMapNumber() {
Expand Down Expand Up @@ -162,7 +162,7 @@ public AdditionalPropertiesClass putMapIntegerItem(String key, Integer mapIntege
* Get mapInteger
* @return mapInteger
**/
@JsonProperty("map_integer")
@JsonProperty(value = "map_integer")
@ApiModelProperty(value = "")

public Map<String, Integer> getMapInteger() {
Expand Down Expand Up @@ -190,7 +190,7 @@ public AdditionalPropertiesClass putMapBooleanItem(String key, Boolean mapBoolea
* Get mapBoolean
* @return mapBoolean
**/
@JsonProperty("map_boolean")
@JsonProperty(value = "map_boolean")
@ApiModelProperty(value = "")

public Map<String, Boolean> getMapBoolean() {
Expand Down Expand Up @@ -218,7 +218,7 @@ public AdditionalPropertiesClass putMapArrayIntegerItem(String key, List<Integer
* Get mapArrayInteger
* @return mapArrayInteger
**/
@JsonProperty("map_array_integer")
@JsonProperty(value = "map_array_integer")
@ApiModelProperty(value = "")
@Valid
public Map<String, List<Integer>> getMapArrayInteger() {
Expand Down Expand Up @@ -246,7 +246,7 @@ public AdditionalPropertiesClass putMapArrayAnytypeItem(String key, List<Object>
* Get mapArrayAnytype
* @return mapArrayAnytype
**/
@JsonProperty("map_array_anytype")
@JsonProperty(value = "map_array_anytype")
@ApiModelProperty(value = "")
@Valid
public Map<String, List<Object>> getMapArrayAnytype() {
Expand Down Expand Up @@ -274,7 +274,7 @@ public AdditionalPropertiesClass putMapMapStringItem(String key, Map<String, Str
* Get mapMapString
* @return mapMapString
**/
@JsonProperty("map_map_string")
@JsonProperty(value = "map_map_string")
@ApiModelProperty(value = "")
@Valid
public Map<String, Map<String, String>> getMapMapString() {
Expand Down Expand Up @@ -302,7 +302,7 @@ public AdditionalPropertiesClass putMapMapAnytypeItem(String key, Map<String, Ob
* Get mapMapAnytype
* @return mapMapAnytype
**/
@JsonProperty("map_map_anytype")
@JsonProperty(value = "map_map_anytype")
@ApiModelProperty(value = "")
@Valid
public Map<String, Map<String, Object>> getMapMapAnytype() {
Expand All @@ -322,7 +322,7 @@ public AdditionalPropertiesClass anytype1(Object anytype1) {
* Get anytype1
* @return anytype1
**/
@JsonProperty("anytype_1")
@JsonProperty(value = "anytype_1")
@ApiModelProperty(value = "")

public Object getAnytype1() {
Expand All @@ -342,7 +342,7 @@ public AdditionalPropertiesClass anytype2(Object anytype2) {
* Get anytype2
* @return anytype2
**/
@JsonProperty("anytype_2")
@JsonProperty(value = "anytype_2")
@ApiModelProperty(value = "")

public Object getAnytype2() {
Expand All @@ -362,7 +362,7 @@ public AdditionalPropertiesClass anytype3(Object anytype3) {
* Get anytype3
* @return anytype3
**/
@JsonProperty("anytype_3")
@JsonProperty(value = "anytype_3")
@ApiModelProperty(value = "")

public Object getAnytype3() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AdditionalPropertiesInteger name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public AdditionalPropertiesNumber name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AdditionalPropertiesObject name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AdditionalPropertiesString name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(value = "")

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Animal className(String className) {
* Get className
* @return className
**/
@JsonProperty("className")
@JsonProperty(value = "className")
@ApiModelProperty(required = true, value = "")
@NotNull
public String getClassName() {
Expand All @@ -77,7 +77,7 @@ public Animal color(String color) {
* Get color
* @return color
**/
@JsonProperty("color")
@JsonProperty(value = "color")
@ApiModelProperty(value = "")

public String getColor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List<BigDecimal> arrayAr
* Get arrayArrayNumber
* @return arrayArrayNumber
**/
@JsonProperty("ArrayArrayNumber")
@JsonProperty(value = "ArrayArrayNumber")
@ApiModelProperty(value = "")
@Valid
public List<List<BigDecimal>> getArrayArrayNumber() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) {
* Get arrayNumber
* @return arrayNumber
**/
@JsonProperty("ArrayNumber")
@JsonProperty(value = "ArrayNumber")
@ApiModelProperty(value = "")
@Valid
public List<BigDecimal> getArrayNumber() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ArrayTest addArrayOfStringItem(String arrayOfStringItem) {
* Get arrayOfString
* @return arrayOfString
**/
@JsonProperty("array_of_string")
@JsonProperty(value = "array_of_string")
@ApiModelProperty(value = "")

public List<String> getArrayOfString() {
Expand Down Expand Up @@ -93,7 +93,7 @@ public ArrayTest addArrayArrayOfIntegerItem(List<Long> arrayArrayOfIntegerItem)
* Get arrayArrayOfInteger
* @return arrayArrayOfInteger
**/
@JsonProperty("array_array_of_integer")
@JsonProperty(value = "array_array_of_integer")
@ApiModelProperty(value = "")
@Valid
public List<List<Long>> getArrayArrayOfInteger() {
Expand Down Expand Up @@ -121,7 +121,7 @@ public ArrayTest addArrayArrayOfModelItem(List<ReadOnlyFirst> arrayArrayOfModelI
* Get arrayArrayOfModel
* @return arrayArrayOfModel
**/
@JsonProperty("array_array_of_model")
@JsonProperty(value = "array_array_of_model")
@ApiModelProperty(value = "")
@Valid
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public BigCat kind(KindEnum kind) {
* Get kind
* @return kind
**/
@JsonProperty("kind")
@JsonProperty(value = "kind")
@ApiModelProperty(value = "")

public KindEnum getKind() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public BigCatAllOf kind(KindEnum kind) {
* Get kind
* @return kind
**/
@JsonProperty("kind")
@JsonProperty(value = "kind")
@ApiModelProperty(value = "")

public KindEnum getKind() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Capitalization smallCamel(String smallCamel) {
* Get smallCamel
* @return smallCamel
**/
@JsonProperty("smallCamel")
@JsonProperty(value = "smallCamel")
@ApiModelProperty(value = "")

public String getSmallCamel() {
Expand All @@ -89,7 +89,7 @@ public Capitalization capitalCamel(String capitalCamel) {
* Get capitalCamel
* @return capitalCamel
**/
@JsonProperty("CapitalCamel")
@JsonProperty(value = "CapitalCamel")
@ApiModelProperty(value = "")

public String getCapitalCamel() {
Expand All @@ -109,7 +109,7 @@ public Capitalization smallSnake(String smallSnake) {
* Get smallSnake
* @return smallSnake
**/
@JsonProperty("small_Snake")
@JsonProperty(value = "small_Snake")
@ApiModelProperty(value = "")

public String getSmallSnake() {
Expand All @@ -129,7 +129,7 @@ public Capitalization capitalSnake(String capitalSnake) {
* Get capitalSnake
* @return capitalSnake
**/
@JsonProperty("Capital_Snake")
@JsonProperty(value = "Capital_Snake")
@ApiModelProperty(value = "")

public String getCapitalSnake() {
Expand All @@ -149,7 +149,7 @@ public Capitalization scAETHFlowPoints(String scAETHFlowPoints) {
* Get scAETHFlowPoints
* @return scAETHFlowPoints
**/
@JsonProperty("SCA_ETH_Flow_Points")
@JsonProperty(value = "SCA_ETH_Flow_Points")
@ApiModelProperty(value = "")

public String getScAETHFlowPoints() {
Expand All @@ -169,7 +169,7 @@ public Capitalization ATT_NAME(String ATT_NAME) {
* Name of the pet
* @return ATT_NAME
**/
@JsonProperty("ATT_NAME")
@JsonProperty(value = "ATT_NAME")
@ApiModelProperty(value = "Name of the pet ")

public String getATTNAME() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Cat declawed(Boolean declawed) {
* Get declawed
* @return declawed
**/
@JsonProperty("declawed")
@JsonProperty(value = "declawed")
@ApiModelProperty(value = "")

public Boolean getDeclawed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CatAllOf declawed(Boolean declawed) {
* Get declawed
* @return declawed
**/
@JsonProperty("declawed")
@JsonProperty(value = "declawed")
@ApiModelProperty(value = "")

public Boolean getDeclawed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Category id(Long id) {
* Get id
* @return id
**/
@JsonProperty("id")
@JsonProperty(value = "id")
@ApiModelProperty(value = "")

public Long getId() {
Expand All @@ -69,7 +69,7 @@ public Category name(String name) {
* Get name
* @return name
**/
@JsonProperty("name")
@JsonProperty(value = "name")
@ApiModelProperty(required = true, value = "")
@NotNull
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ClassModel propertyClass(String propertyClass) {
* Get propertyClass
* @return propertyClass
**/
@JsonProperty("_class")
@JsonProperty(value = "_class")
@ApiModelProperty(value = "")

public String getPropertyClass() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Client client(String client) {
* Get client
* @return client
**/
@JsonProperty("client")
@JsonProperty(value = "client")
@ApiModelProperty(value = "")

public String getClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Dog breed(String breed) {
* Get breed
* @return breed
**/
@JsonProperty("breed")
@JsonProperty(value = "breed")
@ApiModelProperty(value = "")

public String getBreed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public DogAllOf breed(String breed) {
* Get breed
* @return breed
**/
@JsonProperty("breed")
@JsonProperty(value = "breed")
@ApiModelProperty(value = "")

public String getBreed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public EnumArrays justSymbol(JustSymbolEnum justSymbol) {
* Get justSymbol
* @return justSymbol
**/
@JsonProperty("just_symbol")
@JsonProperty(value = "just_symbol")
@ApiModelProperty(value = "")

public JustSymbolEnum getJustSymbol() {
Expand Down Expand Up @@ -142,7 +142,7 @@ public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) {
* Get arrayEnum
* @return arrayEnum
**/
@JsonProperty("array_enum")
@JsonProperty(value = "array_enum")
@ApiModelProperty(value = "")

public List<ArrayEnumEnum> getArrayEnum() {
Expand Down
Loading

0 comments on commit 515d4a0

Please sign in to comment.