-
Notifications
You must be signed in to change notification settings - Fork 138
Deserialize ArrayItems and JsonValueFormat correctly #81
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0f5928c
Deserialize JsonValueFormat
georgewfraser eda54d2
Deserialize ArraySchema
georgewfraser 0f22a28
Format attributes are lowercase http://json-schema.org/latest/json-sc…
georgewfraser b2e04c8
Remove bad toString method
georgewfraser ae77533
Serialize JsonValueFormat using toString
georgewfraser 77d55ee
Test reading of array schemas
georgewfraser d235b4a
Too many cycles of write / read / write loses the order of Set elements
georgewfraser 70648be
ReferenceSchema needs "type" property to deserialize correctly
georgewfraser b52333a
@JsonUnwrapped was on the wrong property
georgewfraser ecaddc0
Need to cycles of write-string / read-JsonSchema to get $ref to be co…
georgewfraser 87da47e
Tests are no longer failing
georgewfraser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/fasterxml/jackson/module/jsonSchema/types/JsonValueFormatDeserializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.fasterxml.jackson.module.jsonSchema.types; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonMappingException; | ||
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; | ||
|
||
import java.io.IOException; | ||
|
||
public class JsonValueFormatDeserializer extends JsonDeserializer<JsonValueFormat> { | ||
@Override | ||
public JsonValueFormat deserialize(JsonParser jsonParser, | ||
DeserializationContext deserializationContext) throws IOException, JsonProcessingException { | ||
String string = jsonParser.getValueAsString(); | ||
|
||
for (JsonValueFormat f : JsonValueFormat.values()) { | ||
if (f.toString().equals(string)) | ||
return f; | ||
} | ||
|
||
throw new JsonMappingException("Expected JsonValueFormat but found " + string); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/fasterxml/jackson/module/jsonSchema/types/JsonValueFormatSerializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.fasterxml.jackson.module.jsonSchema.types; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; | ||
|
||
import java.io.IOException; | ||
|
||
public class JsonValueFormatSerializer extends JsonSerializer<JsonValueFormat> { | ||
|
||
@Override | ||
public void serialize(JsonValueFormat jsonValueFormat, | ||
JsonGenerator jsonGenerator, | ||
SerializerProvider serializerProvider) throws IOException, JsonProcessingException { | ||
jsonGenerator.writeString(jsonValueFormat.toString()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it is legal to use array, or a single item here?
This works, I can probably simplify it after merge a bit.