@@ -20,18 +20,18 @@ public SwaggerDeserializationResult readWithInfo(String location, List<Authoriza
2020 if (location == null ) {
2121 return null ;
2222 }
23- location = location .replaceAll ("\\ \\ " ,"/" );
23+ location = location .replaceAll ("\\ \\ " , "/" );
2424 List <SwaggerParserExtension > parserExtensions = getExtensions ();
2525 SwaggerDeserializationResult output ;
2626
27- if (auths == null ) {
27+ if (auths == null ) {
2828 auths = new ArrayList <AuthorizationValue >();
2929 }
3030
3131 output = new Swagger20Parser ().readWithInfo (location , auths );
3232 if (output != null ) {
33- if (output .getSwagger () != null && "2.0" .equals (output .getSwagger ().getSwagger ())) {
34- if (resolve ) {
33+ if (output .getSwagger () != null && "2.0" .equals (output .getSwagger ().getSwagger ())) {
34+ if (resolve ) {
3535 output .setSwagger (new SwaggerResolver (output .getSwagger (), auths , location ).resolve ());
3636 }
3737 return output ;
@@ -43,9 +43,9 @@ public SwaggerDeserializationResult readWithInfo(String location, List<Authoriza
4343 return output ;
4444 }
4545 }
46- if (output == null ) {
46+ if (output == null ) {
4747 output = new SwaggerDeserializationResult ()
48- .message ("The swagger definition could not be read" );
48+ .message ("The swagger definition could not be read" );
4949 }
5050 return output ;
5151 }
@@ -58,7 +58,7 @@ public Swagger read(String location, List<AuthorizationValue> auths, boolean res
5858 if (location == null ) {
5959 return null ;
6060 }
61- location = location .replaceAll ("\\ \\ " ,"/" );
61+ location = location .replaceAll ("\\ \\ " , "/" );
6262 Swagger output ;
6363
6464 try {
@@ -87,28 +87,7 @@ public Swagger read(String location, List<AuthorizationValue> auths, boolean res
8787 }
8888
8989 public SwaggerDeserializationResult readWithInfo (String swaggerAsString ) {
90- if (swaggerAsString == null ) {
91- return new SwaggerDeserializationResult ().message ("empty or null swagger supplied" );
92- }
93- try {
94- JsonNode node ;
95- if (swaggerAsString .trim ().startsWith ("{" )) {
96- ObjectMapper mapper = Json .mapper ();
97- node = mapper .readTree (swaggerAsString );
98- } else {
99- node = DeserializationUtils .readYamlTree (swaggerAsString );
100- }
101-
102- SwaggerDeserializationResult result = new Swagger20Parser ().readWithInfo (node );
103- if (result != null ) {
104- result .setSwagger (new SwaggerResolver (result .getSwagger (), new ArrayList <AuthorizationValue >(), null ).resolve ());
105- } else {
106- result = new SwaggerDeserializationResult ().message ("Definition does not appear to be a valid Swagger format" );
107- }
108- return result ;
109- } catch (Exception e ) {
110- return new SwaggerDeserializationResult ().message ("malformed or unreadable swagger supplied" );
111- }
90+ return readWithInfo (swaggerAsString , Boolean .TRUE );
11291 }
11392
11493 public SwaggerDeserializationResult readWithInfo (String swaggerAsString , boolean resolve ) {
@@ -173,10 +152,9 @@ public Swagger read(JsonNode node, List<AuthorizationValue> authorizationValues,
173152 try {
174153 output = new Swagger20Parser ().read (node );
175154 if (output != null ) {
176- if (resolve ) {
155+ if (resolve ) {
177156 return new SwaggerResolver (output , authorizationValues ).resolve ();
178- }
179- else {
157+ } else {
180158 return output ;
181159 }
182160 }
0 commit comments