From 779ca6cb979419763d464772f77a0a04ac7ca5fe Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Thu, 3 Feb 2022 19:33:46 -0800 Subject: [PATCH] update Signed-off-by: Jess Frazelle --- VERSION.txt | 2 +- generate/generate.go | 25 ++++++++---------- spec.json | 61 ++++++-------------------------------------- types.go | 10 +++++--- 4 files changed, 26 insertions(+), 72 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 77cada2..41a2819 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -v0.0.6 +v0.0.7 diff --git a/generate/generate.go b/generate/generate.go index 4e9c561..e22f2b8 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -8,6 +8,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "os" "path/filepath" "sort" @@ -22,7 +23,7 @@ import ( var EnumStringTypes map[string][]string = map[string][]string{} func main() { - /*uri := "https://api.kittycad.io" + uri := "https://api.kittycad.io" u, err := url.Parse(uri) if err != nil { fmt.Printf("error parsing url %q: %v\n", uri, err) @@ -34,19 +35,6 @@ func main() { if err != nil { fmt.Printf("error loading openAPI spec from %q: %v\n", uri, err) os.Exit(1) - }*/ - - // Load the open API spec from the file. - wd, err := os.Getwd() - if err != nil { - fmt.Printf("error getting current working directory: %v\n", err) - os.Exit(1) - } - p := filepath.Join(wd, "spec.json") - doc, err := openapi3.NewLoader().LoadFromFile(p) - if err != nil { - fmt.Printf("error loading openAPI spec from file %q: %v\n", p, err) - os.Exit(1) } // Generate the client.go file. @@ -87,6 +75,15 @@ if err != nil { fmt.Printf("error marshalling openAPI spec: %v\n", err) os.Exit(1) } + + // Load the open API spec from the file. + wd, err := os.Getwd() + if err != nil { + fmt.Printf("error getting current working directory: %v\n", err) + os.Exit(1) + } + p := filepath.Join(wd, "spec.json") + if err := ioutil.WriteFile(p, out, 0644); err != nil { fmt.Printf("error writing openAPI spec to %s: %v\n", p, err) os.Exit(1) diff --git a/spec.json b/spec.json index dfd7b0a..d0e8e1e 100644 --- a/spec.json +++ b/spec.json @@ -77,6 +77,7 @@ }, "id": { "description": "The id of the session.", + "format": "uuid", "type": "string" }, "ip_address": { @@ -95,6 +96,7 @@ }, "user_id": { "description": "The user's id.", + "format": "uuid", "type": "string" } }, @@ -132,11 +134,12 @@ }, "id": { "description": "The id of the file conversion.", + "format": "uuid", "type": "string" }, "output": { "description": "The converted file, base64 encoded.", - "format": "base64", + "format": "byte", "type": "string" }, "output_format": { @@ -219,6 +222,7 @@ "type": "object" }, "ValidOutputFileType": { + "description": "The valid file types. note: obj will ignore any associated materials.", "enum": [ "obj", "stl", @@ -227,6 +231,7 @@ "type": "string" }, "ValidSourceFileType": { + "description": "The valid file types. note: obj will ignore any associated materials.", "enum": [ "obj", "stl", @@ -273,19 +278,6 @@ "200": { "content": { "application/json": { - "example": { - "cpu_platform": "Intel Haswell", - "description": "An API server instance.", - "environment": "PRODUCTION", - "git_hash": "d454900", - "hostname": "api-us-central1-0kph.us-central1-f.c.kittycadapi.internal", - "id": "3247495290486004999", - "image": "projects/kittycadapi/global/images/packer-1635462081", - "ip_address": "10.127.15.206", - "machine_type": "projects/199385932268/machineTypes/n1-standard-16", - "name": "api-us-central1-0kph", - "zone": "projects/199385932268/zones/us-central1-f" - }, "schema": { "$ref": "#/components/schemas/InstanceMetadata" } @@ -329,14 +321,6 @@ "200": { "content": { "application/json": { - "example": { - "created_at": "2021-11-02T21:48:05+0000", - "id": "6970d4f2-8979-4461-a9a1-ace62548fb5f", - "ip_address": "203.0.113.0", - "is_valid": true, - "token": "435f9688-365f-4a2d-860b-554798160cfe", - "user_id": "ckv5prd3j000607mlnmwlpyz8" - }, "schema": { "$ref": "#/components/schemas/AuthSession" } @@ -391,14 +375,6 @@ "200": { "content": { "application/json": { - "example": { - "created_at": "2021-11-02T21:48:05+0000", - "id": "6970d4f2-8979-4461-a9a1-ace62548fb5f", - "output_format": "stl", - "src_format": "obj", - "status": "In Progress", - "user_id": "ckv5prd3j000607mlnmwlpyz8" - }, "schema": { "$ref": "#/components/schemas/FileConversion" } @@ -472,7 +448,7 @@ "content": { "text/plain": { "schema": { - "format": "base64", + "format": "byte", "type": "string" } } @@ -484,16 +460,6 @@ "200": { "content": { "application/json": { - "example": { - "completed_at": "2021-11-02T23:12:05+0000", - "created_at": "2021-11-02T21:48:05+0000", - "id": "6970d4f2-8979-4461-a9a1-ace62548fb5f", - "output": "BASE64_ENCODED_FILE_OUTPUT", - "output_format": "stl", - "src_format": "obj", - "status": "Completed", - "user_id": "ckv5prd3j000607mlnmwlpyz8" - }, "schema": { "$ref": "#/components/schemas/FileConversion" } @@ -504,14 +470,6 @@ "202": { "content": { "application/json": { - "example": { - "created_at": "2021-11-02T21:48:05+0000", - "id": "6970d4f2-8979-4461-a9a1-ace62548fb5f", - "output_format": "stl", - "src_format": "obj", - "status": "Uploaded", - "user_id": "ckv5prd3j000607mlnmwlpyz8" - }, "schema": { "$ref": "#/components/schemas/FileConversion" } @@ -550,7 +508,7 @@ "libDocsLink": "https://pkg.go.dev/github.com/kittycad/kittycad.go/#FileService.Convert" }, "x-python": { - "example": "from kittycad.models import FileConversion, ValidFileType\nfrom kittycad.api.file import file_convert_with_base64_helper\nfrom kittycad.types import Response\n\n# Convert a file from STL to OBJ.\n# Read in the contents of the file.\nfile = open(\"example.stl\", \"rb\")\ncontent = file.read()\nfile.close()\n\nfc: FileConversion = file_convert_with_base64_helper.sync(client=client, content=content, source_format=ValidFileType.STL, output_format=ValidFileType.OBJ)\n\n# OR if you need more info (e.g. status_code)\nresponse: Response[FileConversion] = file_convert_with_base64_helper.sync_detailed(client=client, content=content, source_format=ValidFileType.STL, output_format=ValidFileType.OBJ)\n\n# OR run async\nfc: FileConversion = await file_convert_with_base64_helper.asyncio(client=client, content=content, source_format=ValidFileType.STL, output_format=ValidFileType.OBJ)\n\n# OR run async with more info\nresponse: Response[FileConversion] = await file_convert_with_base64_helper.asyncio_detailed(client=client, content=content, source_format=ValidFileType.STL, output_format=ValidFileType.OBJ)\n" + "example": "from kittycad.models import FileConversion, ValidFileType\nfrom kittycad.api.file import file_convert_with_base64_helper\nfrom kittycad.types import Response\n\n# Convert a file from STEP to OBJ.\n# Read in the contents of the file.\nfile = open(\"example.step\", \"rb\")\ncontent = file.read()\nfile.close()\n\nfc: FileConversion = file_convert_with_base64_helper.sync(client=client, content=content, source_format=ValidFileType.STEP, output_format=ValidFileType.OBJ)\n\n# OR if you need more info (e.g. status_code)\nresponse: Response[FileConversion] = file_convert_with_base64_helper.sync_detailed(client=client, content=content, source_format=ValidFileType.STEP, output_format=ValidFileType.OBJ)\n\n# OR run async\nfc: FileConversion = await file_convert_with_base64_helper.asyncio(client=client, content=content, source_format=ValidFileType.STEP, output_format=ValidFileType.OBJ)\n\n# OR run async with more info\nresponse: Response[FileConversion] = await file_convert_with_base64_helper.asyncio_detailed(client=client, content=content, source_format=ValidFileType.STEP, output_format=ValidFileType.OBJ)\n" } } }, @@ -562,9 +520,6 @@ "200": { "content": { "application/json": { - "example": { - "message": "pong" - }, "schema": { "$ref": "#/components/schemas/Message" } diff --git a/types.go b/types.go index eccfeee..3b8537f 100755 --- a/types.go +++ b/types.go @@ -47,9 +47,11 @@ type FileConversion struct { // ID is the id of the file conversion. ID string `json:"id,omitempty" yaml:"id,omitempty"` // Output is the converted file, base64 encoded. - Output string `json:"output,omitempty" yaml:"output,omitempty"` + Output string `json:"output,omitempty" yaml:"output,omitempty"` + // OutputFormat is the valid file types. note: obj will ignore any associated materials. OutputFormat ValidOutputFileType `json:"output_format,omitempty" yaml:"output_format,omitempty"` - SrcFormat ValidSourceFileType `json:"src_format,omitempty" yaml:"src_format,omitempty"` + // SrcFormat is the valid file types. note: obj will ignore any associated materials. + SrcFormat ValidSourceFileType `json:"src_format,omitempty" yaml:"src_format,omitempty"` // Status is the status of the file conversion. Status FileConversionStatus `json:"status,omitempty" yaml:"status,omitempty"` } @@ -102,7 +104,7 @@ type Message struct { Message string `json:"message,omitempty" yaml:"message,omitempty"` } -// ValidOutputFileType is the type definition for a ValidOutputFileType. +// ValidOutputFileType is the valid file types. note: obj will ignore any associated materials. type ValidOutputFileType string const ( @@ -114,7 +116,7 @@ const ( ValidOutputFileTypeDae ValidOutputFileType = "dae" ) -// ValidSourceFileType is the type definition for a ValidSourceFileType. +// ValidSourceFileType is the valid file types. note: obj will ignore any associated materials. type ValidSourceFileType string const (