@@ -16,7 +16,6 @@ import io.vrap.rmf.raml.model.RamlDiagnostic
16
16
import io.vrap.rmf.raml.model.RamlModelBuilder
17
17
import io.vrap.rmf.raml.model.RamlModelResult
18
18
import io.vrap.rmf.raml.model.modules.Api
19
- import io.vrap.rmf.raml.validation.Source
20
19
import io.vrap.rmf.raml.validation.Violation
21
20
import org.eclipse.emf.common.util.Diagnostic
22
21
import org.eclipse.emf.common.util.URI
@@ -199,6 +198,7 @@ class ValidateSubcommand : Callable<Int> {
199
198
OutputFormat .PHP_MARKDOWN -> MarkdownFormatPrinter (linkFormatter)
200
199
OutputFormat .TS_MARKDOWN -> MarkdownFormatPrinter (linkFormatter)
201
200
OutputFormat .DOTNET_MARKDOWN -> MarkdownFormatPrinter (linkFormatter)
201
+ OutputFormat .GITHUB -> GithubFormatPrinter (linkFormatter)
202
202
OutputFormat .JSON -> TODO ()
203
203
}
204
204
}
@@ -280,6 +280,26 @@ class ValidateSubcommand : Callable<Int> {
280
280
}
281
281
}
282
282
283
+ class GithubFormatPrinter (override val linkFormatter : LinkFormatter ): FormatPrinter {
284
+
285
+ override fun print (fileURI : URI , result : RamlModelResult <Api >): String {
286
+ val validationResults = result.validationResults
287
+ var output = " "
288
+ if (validationResults.isNotEmpty()) {
289
+ val errors = validationResults.filter { diagnostic -> diagnostic.severity == Diagnostic .ERROR }
290
+ val warnings = validationResults.filter { diagnostic -> diagnostic.severity == Diagnostic .WARNING }
291
+ val infos = validationResults.filter { diagnostic -> diagnostic.severity == Diagnostic .INFO }
292
+
293
+ if (errors.isNotEmpty()) output + = errors.joinToString(" \n " ) { " ::error file=${java.net.URI .create(it.location).path} ,line=${it.line} ::${it.detailMessage()} " }
294
+ if (warnings.isNotEmpty()) output + = errors.joinToString(" \n " ) { " ::warning file=${java.net.URI .create(it.location).path} ,line=${it.line} ::${it.detailMessage()} " }
295
+ if (infos.isNotEmpty()) output + = errors.joinToString(" \n " ) { " ::notice file=${java.net.URI .create(it.location).path} ,line=${it.line} ::${it.detailMessage()} " }
296
+
297
+ return output
298
+ }
299
+ return " ✅ Specification at ${fileURI.toFileString()} is valid."
300
+ }
301
+ }
302
+
283
303
class MarkdownFormatPrinter (override val linkFormatter : LinkFormatter ): FormatPrinter {
284
304
override fun print (fileURI : URI , result : RamlModelResult <Api >): String {
285
305
val relativeFileLink = Path (fileURI.toFileString()).relativeTo(linkFormatter.filePath)
@@ -321,5 +341,3 @@ class ValidateSubcommand : Callable<Int> {
321
341
}
322
342
}
323
343
}
324
-
325
-
0 commit comments