From abd26b892971d8802bb44246d42d2d241a2a8248 Mon Sep 17 00:00:00 2001 From: Dominic Wong Date: Wed, 22 Sep 2021 11:55:04 +0100 Subject: [PATCH] fix type detection for client generation (#213) --- clients/go/quran/quran.go | 6 +++--- clients/ts/package.json | 2 +- clients/ts/quran/index.ts | 6 +++--- cmd/clients/main.go | 8 ++++---- examples/stream/publish/go/publishAMessage.go | 2 +- quran/proto/quran.proto | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/clients/go/quran/quran.go b/clients/go/quran/quran.go index 2c1481b..3fc090d 100755 --- a/clients/go/quran/quran.go +++ b/clients/go/quran/quran.go @@ -87,7 +87,7 @@ type Result struct { // The associated arabic text Text string `json:"text"` // The related translations to the text - Translations []Interpretation `json:"translations"` + Translations []Translation `json:"translations"` // The unique verse id across the Quran VerseId int32 `json:"verseId"` // The verse key e.g 1:1 @@ -149,7 +149,7 @@ type Verse struct { // The unique id of the verse in the whole book Id int32 `json:"id"` // The interpretations of the verse - Interpretations []Translation `json:"interpretations"` + Interpretations []Interpretation `json:"interpretations"` // The key of this verse (chapter:verse) e.g 1:1 Key string `json:"key"` // The verse number in this chapter @@ -161,7 +161,7 @@ type Verse struct { // The basic translation of the verse TranslatedText string `json:"translatedText"` // The alternative translations for the verse - Translations []Interpretation `json:"translations"` + Translations []Translation `json:"translations"` // The phonetic transliteration from arabic Transliteration string `json:"transliteration"` // The individual words within the verse (Ayah) diff --git a/clients/ts/package.json b/clients/ts/package.json index 6217534..283f361 100644 --- a/clients/ts/package.json +++ b/clients/ts/package.json @@ -60,5 +60,5 @@ }, "type": "module", "types": "dist/index.d.ts", - "version": "1.0.525" + "version": "1.0.526" } \ No newline at end of file diff --git a/clients/ts/quran/index.ts b/clients/ts/quran/index.ts index 77f59a9..ecac3c8 100755 --- a/clients/ts/quran/index.ts +++ b/clients/ts/quran/index.ts @@ -87,7 +87,7 @@ export interface Result { // The associated arabic text text?: string; // The related translations to the text - translations?: Interpretation[]; + translations?: Translation[]; // The unique verse id across the Quran verseId?: number; // The verse key e.g 1:1 @@ -149,7 +149,7 @@ export interface Verse { // The unique id of the verse in the whole book id?: number; // The interpretations of the verse - interpretations?: Translation[]; + interpretations?: Interpretation[]; // The key of this verse (chapter:verse) e.g 1:1 key?: string; // The verse number in this chapter @@ -161,7 +161,7 @@ export interface Verse { // The basic translation of the verse translatedText?: string; // The alternative translations for the verse - translations?: Interpretation[]; + translations?: Translation[]; // The phonetic transliteration from arabic transliteration?: string; // The individual words within the verse (Ayah) diff --git a/cmd/clients/main.go b/cmd/clients/main.go index c142cc8..e6c4185 100644 --- a/cmd/clients/main.go +++ b/cmd/clients/main.go @@ -201,7 +201,7 @@ func main() { cmd.Dir = filepath.Join(tsPath, serviceName) outp, err = cmd.CombinedOutput() if err != nil { - fmt.Println(fmt.Sprintf("Problem formatting '%v' client: %v", serviceName, string(outp))) + fmt.Println(fmt.Sprintf("Problem formatting '%v' client: %v %s", serviceName, string(outp), err.Error())) os.Exit(1) } @@ -595,8 +595,9 @@ func schemaToType(language, serviceName, typeName string, schemas map[string]*op detectType := func(currentType string, properties map[string]*openapi3.SchemaRef) (string, bool) { index := map[string]bool{} for key, prop := range properties { - index[key+prop.Value.Title] = true + index[key+prop.Value.Title+prop.Value.Description] = true } + for k, schema := range schemas { // we don't want to return the type matching itself if strings.ToLower(k) == currentType { @@ -610,8 +611,7 @@ func schemaToType(language, serviceName, typeName string, schemas map[string]*op } found := false for key, prop := range schema.Value.Properties { - - _, ok := index[key+prop.Value.Title] + _, ok := index[key+prop.Value.Title+prop.Value.Description] found = ok if !ok { break diff --git a/examples/stream/publish/go/publishAMessage.go b/examples/stream/publish/go/publishAMessage.go index 0f33eac..af88ee1 100755 --- a/examples/stream/publish/go/publishAMessage.go +++ b/examples/stream/publish/go/publishAMessage.go @@ -11,9 +11,9 @@ func PublishAmessage() { streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN")) rsp, err := streamService.Publish(&stream.PublishRequest{ Message: map[string]interface{}{ - "user": "john", "id": "1", "type": "signup", + "user": "john", }, Topic: "events", }) diff --git a/quran/proto/quran.proto b/quran/proto/quran.proto index 3262e3c..f17422b 100644 --- a/quran/proto/quran.proto +++ b/quran/proto/quran.proto @@ -17,7 +17,7 @@ message Chapter { // The number of verses in the chapter int32 verses = 2; // The simple name of the chapter - string name = 3; + string name = 3; // The arabic name of the chapter string arabic_name = 4; // The complex name of the chapter