Skip to content

Commit

Permalink
Merge pull request #60 from Cosium/readonly-property
Browse files Browse the repository at this point in the history
Add a readonly property
  • Loading branch information
cowtowncoder committed Feb 17, 2015
2 parents fac66e4 + 2ef3e51 commit f66545e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ public abstract class JsonSchema
@JsonProperty
private Boolean required = null;

/**
* This attribute indicates if the instance is not modifiable.
* This is false by defaul, making the instance modifiable.
*/
@JsonProperty
private Boolean readonly = null;

/**
* This attribute is a string that provides a full description of the of
* purpose the instance property.
Expand Down Expand Up @@ -271,6 +278,7 @@ public boolean equals(Object obj) {
JsonSchema that = ((JsonSchema)obj);
return equals(getType(), getType()) &&
equals(getRequired(), that.getRequired()) &&
equals(getReadonly(), that.getReadonly()) &&
equals(get$ref(), that.get$ref()) &&
equals(get$schema(), that.get$schema()) &&
equals(getDisallow(), that.getDisallow()) &&
Expand Down Expand Up @@ -301,6 +309,10 @@ public Boolean getRequired() {
return required;
}

public Boolean getReadonly() {
return readonly;
}

public String getDescription() {
return description;
}
Expand Down Expand Up @@ -453,6 +465,10 @@ public void setRequired(Boolean required) {
this.required = required;
}

public void setReadonly(Boolean readonly){
this.readonly = readonly;
}

public void setDescription(String description) {
this.description = description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,19 @@ public void testGeneratingJsonSchema() throws Exception {
assertNotNull(prop1);
assertTrue(prop1.isIntegerSchema());
assertNull(prop1.getRequired());
assertNull(prop1.getReadonly());

JsonSchema prop2 = properties.get("property2");
assertNotNull(prop2);
assertTrue(prop2.isStringSchema());
assertNull(prop2.getRequired());
assertNull(prop2.getReadonly());

JsonSchema prop3 = properties.get("property3");
assertNotNull(prop3);
assertTrue(prop3.isArraySchema());
assertNull(prop3.getRequired());
assertNull(prop3.getReadonly());
Items items = prop3.asArraySchema().getItems();
assertTrue(items.isSingleItems());
JsonSchema itemType = items.asSingleItems().getSchema();
Expand All @@ -161,6 +164,7 @@ public void testGeneratingJsonSchema() throws Exception {
assertNotNull(prop4);
assertTrue(prop4.isArraySchema());
assertNull(prop4.getRequired());
assertNull(prop4.getReadonly());
items = prop4.asArraySchema().getItems();
assertTrue(items.isSingleItems());
itemType = items.asSingleItems().getSchema();
Expand All @@ -170,6 +174,7 @@ public void testGeneratingJsonSchema() throws Exception {
JsonSchema prop5 = properties.get("property5");
assertNotNull(prop5);
assertTrue(prop5.getRequired());
assertNull(prop5.getReadonly());

}

Expand Down

0 comments on commit f66545e

Please sign in to comment.