mirror of
https://github.com/foss42/apidash.git
synced 2025-09-21 12:41:23 +08:00
Configurable codegen highlight language and file extension
This commit is contained in:
@ -230,11 +230,13 @@ const kDefaultHttpMethod = HTTPVerb.get;
|
||||
const kDefaultContentType = ContentType.json;
|
||||
|
||||
enum CodegenLanguage {
|
||||
dartHttp("Dart (http)"),
|
||||
kotlinOkHttp("Kotlin (OkHttp)");
|
||||
dartHttp("Dart (http)", "dart", "dart"),
|
||||
kotlinOkHttp("Kotlin (OkHttp)", "java", "kt");
|
||||
|
||||
const CodegenLanguage(this.label);
|
||||
const CodegenLanguage(this.label, this.codeHighlightLang, this.ext);
|
||||
final String label;
|
||||
final String codeHighlightLang;
|
||||
final String ext;
|
||||
}
|
||||
|
||||
const JsonEncoder kEncoder = JsonEncoder.withIndent(' ');
|
||||
|
@ -160,7 +160,7 @@ class _ViewCodePaneState extends State<ViewCodePane> {
|
||||
),
|
||||
SaveInDownloadsButton(
|
||||
content: stringToBytes(widget.code),
|
||||
mimeType: "application/vnd.dart",
|
||||
ext: widget.codegenLanguage.ext,
|
||||
showLabel: showLabel,
|
||||
)
|
||||
],
|
||||
@ -175,7 +175,7 @@ class _ViewCodePaneState extends State<ViewCodePane> {
|
||||
child: CodeGenPreviewer(
|
||||
code: widget.code,
|
||||
theme: codeTheme,
|
||||
language: 'dart',
|
||||
language: widget.codegenLanguage.codeHighlightLang,
|
||||
textStyle: kCodeStyle,
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user