mirror of
https://github.com/teamhanko/hanko.git
synced 2025-11-01 19:18:53 +08:00
chore: delete schema generator
This commit is contained in:
committed by
Lennart Fleischmann
parent
a0740afbd1
commit
68e562cba8
@ -1,42 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/invopop/jsonschema"
|
||||
"github.com/teamhanko/hanko/backend/cmd/user"
|
||||
"github.com/teamhanko/hanko/backend/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := generateSchema("./config", "./json_schema/hanko.config.json", &config.Config{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := generateSchema("./cmd/user", "./json_schema/hanko.user_import.json", &user.ImportOrExportList{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func generateSchema(codePath, filePath string, structure interface{}) error {
|
||||
r := new(jsonschema.Reflector)
|
||||
|
||||
if err := r.AddGoComments("github.com/teamhanko/hanko/backend", codePath); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
s := r.Reflect(structure)
|
||||
|
||||
data, err := json.MarshalIndent(s, "", " ")
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
err = os.WriteFile(filePath, data, 0600)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user