@@ -97,6 +97,25 @@ public void shouldConvertIntoDirectoryIfInputIsDirectory() throws Exception {
9797 assertThat (outputFiles ).containsOnly ("definitions.adoc" , "overview.adoc" , "paths.adoc" , "security.adoc" );
9898 }
9999
100+ @ Test
101+ public void shouldConvertIntoDirectoryIfInputIsDirectoryWithMixedSeparators () throws Exception {
102+ //given that the input folder contains a nested structure with Swagger files but path to it contains mixed file
103+ //separators on Windows (/ and \)
104+ Swagger2MarkupMojo mojo = new Swagger2MarkupMojo ();
105+ String swaggerInputPath = new File (RESOURCES_DIR ).getAbsoluteFile ().getAbsolutePath ();
106+ mojo .swaggerInput = replaceLast (swaggerInputPath , "\\ " , "/" );
107+ mojo .outputDir = new File (OUTPUT_DIR ).getAbsoluteFile ();
108+
109+ //when
110+ mojo .execute ();
111+
112+ //then
113+ Iterable <String > outputFiles = recursivelyListFileNames (new File (mojo .outputDir , SWAGGER_DIR ));
114+ assertThat (outputFiles ).containsOnly ("definitions.adoc" , "overview.adoc" , "paths.adoc" , "security.adoc" );
115+ outputFiles = listFileNames (new File (mojo .outputDir , SWAGGER_DIR + "2" ), false );
116+ assertThat (outputFiles ).containsOnly ("definitions.adoc" , "overview.adoc" , "paths.adoc" , "security.adoc" );
117+ }
118+
100119 @ Test
101120 public void shouldConvertIntoSubDirectoryIfMultipleSwaggerFilesInSameInput () throws Exception {
102121 //given that the input folder contains two Swagger files
@@ -123,7 +142,7 @@ public void shouldConvertIntoSubDirectoryOneFileIfMultipleSwaggerFilesInSameInpu
123142 mojo .swaggerInput = new File (INPUT_DIR ).getAbsoluteFile ().getAbsolutePath ();
124143 mojo .outputDir = new File (OUTPUT_DIR ).getAbsoluteFile ();
125144 mojo .outputFile = new File (SWAGGER_OUTPUT_FILE );
126-
145+
127146 //when
128147 mojo .execute ();
129148
@@ -208,4 +227,15 @@ private static Iterable<String> listFileNames(File dir, boolean recursive) {
208227 private static void verifyFileContains (File file , String value ) throws IOException {
209228 assertThat (IOUtils .toString (file .toURI (), StandardCharsets .UTF_8 )).contains (value );
210229 }
230+
231+ private static String replaceLast (String input , String search , String replace ) {
232+ int lastIndex = input .lastIndexOf (search );
233+ if (lastIndex > -1 ) {
234+ return input .substring (0 , lastIndex )
235+ + replace
236+ + input .substring (lastIndex + search .length (), input .length ());
237+ } else {
238+ return input ;
239+ }
240+ }
211241}
0 commit comments