-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow returning 3.1 schema types in 'getType'
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
36 changes: 36 additions & 0 deletions
36
modules/swagger-core/src/main/java/io/swagger/v3/core/util/OpenAPI31Deserializer.java
This file contains 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,36 @@ | ||
package io.swagger.v3.core.util; | ||
|
||
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.deser.ResolvableDeserializer; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.SpecVersion; | ||
|
||
import java.io.IOException; | ||
|
||
public class OpenAPI31Deserializer extends StdDeserializer<OpenAPI> implements ResolvableDeserializer { | ||
|
||
private final JsonDeserializer<?> defaultDeserializer; | ||
|
||
public OpenAPI31Deserializer(JsonDeserializer<?> defaultDeserializer) | ||
{ | ||
super(OpenAPI.class); | ||
this.defaultDeserializer = defaultDeserializer; | ||
} | ||
|
||
@Override | ||
public OpenAPI deserialize(JsonParser jp, DeserializationContext ctxt) | ||
throws IOException, JsonProcessingException { | ||
OpenAPI openAPI = (OpenAPI) defaultDeserializer.deserialize(jp, ctxt); | ||
openAPI.setSpecVersion(SpecVersion.V31); | ||
return openAPI; | ||
} | ||
@Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { | ||
((ResolvableDeserializer) defaultDeserializer).resolve(ctxt); | ||
} | ||
} | ||
|
This file contains 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