@@ -119,6 +119,7 @@ public void processMediaType(MediaType mediaType, String relativePath, boolean d
119119 }
120120
121121 private void putComponentExample (String key , Example example ) {
122+ log .debug ("Put Component Example: [{}], [{}]" , key , example );
122123 getComponentExamplesFromOpenAPI ().put (key , example );
123124 }
124125
@@ -155,7 +156,6 @@ private void fixInlineExamples(ExampleHolder exampleHolder, String relativePath,
155156 return ;
156157 }
157158
158- URI resolvedUri ;
159159 Optional <String > fragment ;
160160 if (refPath .contains ("#" ) && !refPath .startsWith ("#/components/examples" )) {
161161 fragment = Optional .of (StringUtils .substringAfter (refPath , "#" ));
@@ -164,11 +164,12 @@ private void fixInlineExamples(ExampleHolder exampleHolder, String relativePath,
164164 fragment = Optional .empty ();
165165 }
166166
167- resolvedUri = resolveUri (relativePath , refPath );
167+ URI resolvedUri = resolveUri (relativePath , refPath );
168168 try {
169169 String content = readContent (Paths .get (resolvedUri ));
170170
171171 if (fragment .isPresent ()) {
172+ log .debug ("Read content from [{}], finding fragment [{}]" , resolvedUri , fragment .get ());
172173 String exampleName = StringUtils .substringAfterLast (fragment .get (), "/" );
173174 // resolve fragment from json node
174175 JsonNode jsonNode = yamlObjectMapper .readTree (content );
@@ -178,19 +179,22 @@ private void fixInlineExamples(ExampleHolder exampleHolder, String relativePath,
178179 processInLineExample (exampleHolder ,relativePath ,exampleNode , exampleName );
179180
180181 } else {
182+ log .debug ("Read content from [{}], set content and dereference" , resolvedUri );
181183 exampleHolder .setContent (content );
182184 dereferenceExample (exampleHolder );
183185 }
184186 if (derefenceExamples ) {
187+ log .debug ("Read content from [{}], not setting content and dereference because..." , resolvedUri );
185188 dereferenceExample (exampleHolder );
186189 }
187190
188191 } catch (IOException e ) {
189- throw new TransformerException ("Unable to fix inline examples" , e );
192+ throw new TransformerException ("Unable to fix inline examples from " + resolvedUri , e );
190193 }
191194 }
192195
193196 private void processInLineExample (ExampleHolder exampleHolder , String relativePath , JsonNode exampleNode , String exampleName ) throws IOException {
197+ log .debug ("Process inline example [{}], [{}], [{}], [{}]" , exampleHolder , relativePath , exampleNode , exampleName );
194198 if (exampleNode .has ("$ref" )) {
195199 String refPath = exampleNode .get ("$ref" ).asText ();
196200 exampleHolder .replaceRef (refPath );
@@ -227,17 +231,23 @@ private String readContent(Path path) throws IOException {
227231 }
228232
229233 private URI resolveUri (String relativePath , String refPath ) {
230- URI resolvedUri ;
231234 if (relativePath == null ) {
232- resolvedUri = rootUri .resolve (StringUtils . strip (refPath , "./" ));
235+ return rootUri .resolve (removeTrainingDotSlash (refPath ));
233236 } else {
234- resolvedUri = rootUri .resolve (checkTrailingSlash (relativePath .replace ("\\ " , "/" )))
237+ return rootUri .resolve (checkTrailingSlash (relativePath .replace ("\\ " , "/" )))
235238 .resolve (refPath .replace ("\\ " , "/" ));
236239 }
237- return resolvedUri ;
240+ }
241+
242+ private String removeTrainingDotSlash (String path ) {
243+ if (StringUtils .startsWith (path ,"./" )) {
244+ return StringUtils .substring (path , 2 );
245+ }
246+ return path ;
238247 }
239248
240249 private void dereferenceExample (ExampleHolder exampleHolder ) {
250+ log .debug ("dereferenceExample: '{}'" , exampleHolder );
241251 String rootName = exampleHolder .getExampleName ();
242252 int count = 0 ;
243253 while (existsButNotMatching (cache .get (makeCountedName (rootName , count )), exampleHolder )) {
0 commit comments