mirror of
https://github.com/foss42/apidash.git
synced 2025-09-21 04:22:50 +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;
|
const kDefaultContentType = ContentType.json;
|
||||||
|
|
||||||
enum CodegenLanguage {
|
enum CodegenLanguage {
|
||||||
dartHttp("Dart (http)"),
|
dartHttp("Dart (http)", "dart", "dart"),
|
||||||
kotlinOkHttp("Kotlin (OkHttp)");
|
kotlinOkHttp("Kotlin (OkHttp)", "java", "kt");
|
||||||
|
|
||||||
const CodegenLanguage(this.label);
|
const CodegenLanguage(this.label, this.codeHighlightLang, this.ext);
|
||||||
final String label;
|
final String label;
|
||||||
|
final String codeHighlightLang;
|
||||||
|
final String ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
const JsonEncoder kEncoder = JsonEncoder.withIndent(' ');
|
const JsonEncoder kEncoder = JsonEncoder.withIndent(' ');
|
||||||
|
@ -160,7 +160,7 @@ class _ViewCodePaneState extends State<ViewCodePane> {
|
|||||||
),
|
),
|
||||||
SaveInDownloadsButton(
|
SaveInDownloadsButton(
|
||||||
content: stringToBytes(widget.code),
|
content: stringToBytes(widget.code),
|
||||||
mimeType: "application/vnd.dart",
|
ext: widget.codegenLanguage.ext,
|
||||||
showLabel: showLabel,
|
showLabel: showLabel,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -175,7 +175,7 @@ class _ViewCodePaneState extends State<ViewCodePane> {
|
|||||||
child: CodeGenPreviewer(
|
child: CodeGenPreviewer(
|
||||||
code: widget.code,
|
code: widget.code,
|
||||||
theme: codeTheme,
|
theme: codeTheme,
|
||||||
language: 'dart',
|
language: widget.codegenLanguage.codeHighlightLang,
|
||||||
textStyle: kCodeStyle,
|
textStyle: kCodeStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user