Skip to content

Commit f66545e

Browse files
committed
Merge pull request #60 from Cosium/readonly-property
Add a readonly property
2 parents fac66e4 + 2ef3e51 commit f66545e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/main/java/com/fasterxml/jackson/module/jsonSchema/JsonSchema.java

+16
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ public abstract class JsonSchema
148148
@JsonProperty
149149
private Boolean required = null;
150150

151+
/**
152+
* This attribute indicates if the instance is not modifiable.
153+
* This is false by defaul, making the instance modifiable.
154+
*/
155+
@JsonProperty
156+
private Boolean readonly = null;
157+
151158
/**
152159
* This attribute is a string that provides a full description of the of
153160
* purpose the instance property.
@@ -271,6 +278,7 @@ public boolean equals(Object obj) {
271278
JsonSchema that = ((JsonSchema)obj);
272279
return equals(getType(), getType()) &&
273280
equals(getRequired(), that.getRequired()) &&
281+
equals(getReadonly(), that.getReadonly()) &&
274282
equals(get$ref(), that.get$ref()) &&
275283
equals(get$schema(), that.get$schema()) &&
276284
equals(getDisallow(), that.getDisallow()) &&
@@ -301,6 +309,10 @@ public Boolean getRequired() {
301309
return required;
302310
}
303311

312+
public Boolean getReadonly() {
313+
return readonly;
314+
}
315+
304316
public String getDescription() {
305317
return description;
306318
}
@@ -453,6 +465,10 @@ public void setRequired(Boolean required) {
453465
this.required = required;
454466
}
455467

468+
public void setReadonly(Boolean readonly){
469+
this.readonly = readonly;
470+
}
471+
456472
public void setDescription(String description) {
457473
this.description = description;
458474
}

src/test/java/com/fasterxml/jackson/module/jsonSchema/TestGenerateJsonSchema.java

+5
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,19 @@ public void testGeneratingJsonSchema() throws Exception {
141141
assertNotNull(prop1);
142142
assertTrue(prop1.isIntegerSchema());
143143
assertNull(prop1.getRequired());
144+
assertNull(prop1.getReadonly());
144145

145146
JsonSchema prop2 = properties.get("property2");
146147
assertNotNull(prop2);
147148
assertTrue(prop2.isStringSchema());
148149
assertNull(prop2.getRequired());
150+
assertNull(prop2.getReadonly());
149151

150152
JsonSchema prop3 = properties.get("property3");
151153
assertNotNull(prop3);
152154
assertTrue(prop3.isArraySchema());
153155
assertNull(prop3.getRequired());
156+
assertNull(prop3.getReadonly());
154157
Items items = prop3.asArraySchema().getItems();
155158
assertTrue(items.isSingleItems());
156159
JsonSchema itemType = items.asSingleItems().getSchema();
@@ -161,6 +164,7 @@ public void testGeneratingJsonSchema() throws Exception {
161164
assertNotNull(prop4);
162165
assertTrue(prop4.isArraySchema());
163166
assertNull(prop4.getRequired());
167+
assertNull(prop4.getReadonly());
164168
items = prop4.asArraySchema().getItems();
165169
assertTrue(items.isSingleItems());
166170
itemType = items.asSingleItems().getSchema();
@@ -170,6 +174,7 @@ public void testGeneratingJsonSchema() throws Exception {
170174
JsonSchema prop5 = properties.get("property5");
171175
assertNotNull(prop5);
172176
assertTrue(prop5.getRequired());
177+
assertNull(prop5.getReadonly());
173178

174179
}
175180

0 commit comments

Comments
 (0)