Skip to content

Commit

Permalink
fixed missing comma after attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Katzen48 committed Mar 31, 2023
1 parent 3549f79 commit 9b12858
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/openApiFormatter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const {request} = require("playwright");
const HOST = 'api.twitch.tv';
const BASE_PATH = '/helix';
const SCHEME = 'https';
Expand Down Expand Up @@ -59,7 +60,7 @@ const formatter = {
}

try {
let json = example.replaceAll('\n', '')
json = example/*.replaceAll('\n', '')*/
// Get rid of `...` in the beginning of an object
.replace(new RegExp("[\\{][\\s]*([\\.][\\s]?){3}(?=[\\s]*[\"])", "g"), "{")
// Get rid of `...` in the middle of an object
Expand All @@ -74,6 +75,10 @@ const formatter = {
// Get rid of `...` at the end of an array
.replace(new RegExp("[}][,]?[\\s]*([\\.][\\s]?){3}(?=[\\s]*[\\]])", "g"), "}")


// Add missing comma after attribute
.replace(new RegExp("(?<![,{[])\\n(?=[\\s]*[\"])", "g"), ",\n")

// Get rid of trailing comma at the end of an array
.replace(new RegExp("[}][,][\\s]*(?=[\\s]*[\\]])", "g"), "}");

Expand Down

0 comments on commit 9b12858

Please sign in to comment.