diff --git a/pkg/create_html_output.go b/pkg/create_html_output.go index ec3130e..1e725ae 100644 --- a/pkg/create_html_output.go +++ b/pkg/create_html_output.go @@ -70,13 +70,13 @@ func RenderContent(w io.Writer, crdContent []byte, comments, minimal bool) error parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, comments, minimal) for _, version := range crd.Spec.Versions { - out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, minimal, rootRequiredFields) + out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, minimal, RootRequiredFields) if err != nil { return fmt.Errorf("failed to parse properties: %w", err) } var buffer []byte buf := bytes.NewBuffer(buffer) - if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields); err != nil { + if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields); err != nil { return fmt.Errorf("failed to generate yaml sample: %w", err) } versions = append(versions, Version{ diff --git a/pkg/generate.go b/pkg/generate.go index d045cef..edf7dd2 100644 --- a/pkg/generate.go +++ b/pkg/generate.go @@ -13,7 +13,7 @@ import ( const array = "array" -var rootRequiredFields = []string{"apiVersion", "kind", "spec"} +var RootRequiredFields = []string{"apiVersion", "kind", "spec"} // Generate takes a CRD content and path, and outputs. func Generate(crd *v1beta1.CustomResourceDefinition, w io.WriteCloser, enableComments, minimal bool) (err error) { @@ -24,7 +24,7 @@ func Generate(crd *v1beta1.CustomResourceDefinition, w io.WriteCloser, enableCom }() parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, enableComments, minimal) for i, version := range crd.Spec.Versions { - if err := parser.ParseProperties(version.Name, w, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields); err != nil { + if err := parser.ParseProperties(version.Name, w, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields); err != nil { return fmt.Errorf("failed to parse properties: %w", err) } diff --git a/pkg/generate_test.go b/pkg/generate_test.go index 5886d6e..1febcaf 100644 --- a/pkg/generate_test.go +++ b/pkg/generate_test.go @@ -24,7 +24,7 @@ func TestGenerate(t *testing.T) { version := crd.Spec.Versions[0] parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, false, false) - require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields)) + require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields)) golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_golden.yaml")) require.NoError(t, err) @@ -44,7 +44,7 @@ func TestGenerateWithExample(t *testing.T) { parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, false, false) version := crd.Spec.Versions[0] - require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields)) + require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields)) golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_with_example_golden.yaml")) require.NoError(t, err) @@ -64,7 +64,7 @@ func TestGenerateWithComments(t *testing.T) { parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, true, false) version := crd.Spec.Versions[0] - require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields)) + require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields)) golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_with_comments_golden.yaml")) require.NoError(t, err) @@ -84,7 +84,7 @@ func TestGenerateMinimal(t *testing.T) { parser := NewParser(crd.Spec.Group, crd.Spec.Names.Kind, false, true) version := crd.Spec.Versions[0] - require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, rootRequiredFields)) + require.NoError(t, parser.ParseProperties(version.Name, buffer, version.Schema.OpenAPIV3Schema.Properties, RootRequiredFields)) golden, err := os.ReadFile(filepath.Join("testdata", "sample_crd_with_minimal_example_golden.yaml")) require.NoError(t, err) diff --git a/wasm/app-worker.js b/wasm/app-worker.js index 6672202..85ab5ac 100644 --- a/wasm/app-worker.js +++ b/wasm/app-worker.js @@ -1,8 +1,8 @@ -const cacheName = "app-" + "f12aae0089af3c57e2d86eef472876387bf42dc1"; +const cacheName = "app-" + "ee6c5e01e67fb9a1abeb60d8500657a8ab5d0628"; const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/alert.css","/web/img/logo.png","https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js","https://cdn.jsdelivr.net/npm/halfmoon@2.0.1/css/halfmoon.min.css","https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js","https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css","https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-twilight.min.css"]; self.addEventListener("install", (event) => { - console.log("installing app worker f12aae0089af3c57e2d86eef472876387bf42dc1"); + console.log("installing app worker ee6c5e01e67fb9a1abeb60d8500657a8ab5d0628"); event.waitUntil( caches @@ -28,7 +28,7 @@ self.addEventListener("activate", (event) => { ); }) ); - console.log("app worker f12aae0089af3c57e2d86eef472876387bf42dc1 is activated"); + console.log("app worker ee6c5e01e67fb9a1abeb60d8500657a8ab5d0628 is activated"); }); self.addEventListener("fetch", (event) => { diff --git a/wasm/app.go b/wasm/app.go index c8b4985..a8a8758 100644 --- a/wasm/app.go +++ b/wasm/app.go @@ -62,7 +62,7 @@ func (h *crdView) Render() app.UI { } versions := make([]Version, 0) - parser := pkg.NewParser(crd.Spec.Group, crd.Spec.Names.Kind, h.comment) + parser := pkg.NewParser(crd.Spec.Group, crd.Spec.Names.Kind, h.comment, false) for _, version := range crd.Spec.Versions { out, err := parseCRD(version.Schema.OpenAPIV3Schema.Properties, version.Name, version.Schema.OpenAPIV3Schema.Required) if err != nil { @@ -70,7 +70,7 @@ func (h *crdView) Render() app.UI { } var buffer []byte buf := bytes.NewBuffer(buffer) - if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties); err != nil { + if err := parser.ParseProperties(version.Name, buf, version.Schema.OpenAPIV3Schema.Properties, pkg.RootRequiredFields); err != nil { return h.buildError(err) } versions = append(versions, Version{ diff --git a/wasm/app.js b/wasm/app.js index 86708ff..d9ebba7 100644 --- a/wasm/app.js +++ b/wasm/app.js @@ -5,7 +5,7 @@ var goappNav = function () {}; var goappOnUpdate = function () {}; var goappOnAppInstallChange = function () {}; -const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"f12aae0089af3c57e2d86eef472876387bf42dc1"}; +const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"ee6c5e01e67fb9a1abeb60d8500657a8ab5d0628"}; const goappLoadingLabel = "{progress}%"; const goappWasmContentLengthHeader = ""; diff --git a/wasm/index.html b/wasm/index.html index d3f7d8b..14d04b6 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -7,7 +7,7 @@ - + @@ -15,17 +15,17 @@