Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a readonly property #60

Merged
merged 1 commit into from
Feb 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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