Postman and openAPI specs (#174)

This commit is contained in:
Dominic Wong
2021-06-29 15:50:06 +01:00
committed by GitHub
parent d212fd2f5c
commit 221ff019af
6 changed files with 46 additions and 61 deletions

View File

@@ -47,11 +47,11 @@ var cases = []tspec{
}`,
key: "QueryRequest",
tsresult: `export interface QueryRequest {
id?: string;
limit?: number;
offset?: number;
slug?: number;
tag?: number;
id?: number;
slug?: string;
tag?: string;
}`,
},
{
@@ -120,18 +120,18 @@ var cases = []tspec{
tsresult: `
export interface QueryResponse {
posts?: {
metadata?: {
value?: string;
key?: string;
}[];
slug?: string;
title?: string;
author?: string;
content?: string;
created?: number;
id?: string;
image?: string;
author?: string;
metadata?: {
key?: string;
value?: string;
}[];
slug?: string;
tags?: string[];
title?: string;
updated?: number;
}[];
}`,

View File

@@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
"github.com/Masterminds/semver/v3"
@@ -181,7 +182,13 @@ func schemaToTs(title string, spec *openapi3.SchemaRef) string {
ret := ""
i := 0
for k, v := range props {
var keys []string
for k := range props {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := props[k]
ret += strings.Repeat(" ", level)
k = strcase.SnakeCase(k)
//v.Value.