Chore: switches to new oapi type field type (#6794)
CodeQL / Analyze (go) (push) Waiting to run Details
Definition-Lint / definition-doc (push) Waiting to run Details
E2E MultiCluster Test / detect-noop (push) Waiting to run Details
E2E MultiCluster Test / e2e-multi-cluster-tests (v1.29) (push) Blocked by required conditions Details
E2E Test / detect-noop (push) Waiting to run Details
E2E Test / e2e-tests (v1.29) (push) Blocked by required conditions Details
Go / detect-noop (push) Waiting to run Details
Go / staticcheck (push) Blocked by required conditions Details
Go / lint (push) Blocked by required conditions Details
Go / check-diff (push) Blocked by required conditions Details
Go / check-windows (push) Blocked by required conditions Details
Go / check-core-image-build (push) Blocked by required conditions Details
Go / check-cli-image-build (push) Blocked by required conditions Details
license / Check for unapproved licenses (push) Waiting to run Details
Registry / Build and Push Vela Images (push) Waiting to run Details
Registry / Generate and Push Provenance to GCHR (${{ needs.publish-vela-images.outputs.vela_cli_digest }}, ${{ needs.publish-vela-images.outputs.vela_cli_image }}, Vela CLI Image) (push) Blocked by required conditions Details
Registry / Generate and Push Provenance to GCHR (${{ needs.publish-vela-images.outputs.vela_core_digest }}, ${{ needs.publish-vela-images.outputs.vela_core_image }}, Vela Core Image) (push) Blocked by required conditions Details
Registry / Generate and Push Provenance to DockerHub (${{ needs.publish-vela-images.outputs.vela_cli_digest }}, ${{ needs.publish-vela-images.outputs.vela_cli_dockerhub_image }}, Vela CLI Image) (push) Blocked by required conditions Details
Registry / Generate and Push Provenance to DockerHub (${{ needs.publish-vela-images.outputs.vela_core_digest }}, ${{ needs.publish-vela-images.outputs.vela_core_dockerhub_image }}, Vela Core Image) (push) Blocked by required conditions Details
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run Details
Unit-Test / detect-noop (push) Waiting to run Details
Unit-Test / unit-tests (push) Blocked by required conditions Details
Sync SDK / sync_sdk (push) Has been cancelled Details

* chore: switches to new oapi type field type

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: updates gen_sdk to use the new schema type

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: updates gen_sdk_test to use the new schema type

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: updates schema to use the new schema type

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* fix: updates chart urls

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: changes from make reviewable

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: fixes linting errors

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* debugging test failure

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* fix: fixes schema type nil check

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: replaces literals with constants

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* debugging test failure

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* test: switches to the new addon registry url

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* chore: extra line removal

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* fix: replaces deprecated urls

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* fix: removes extra quotes form marshaljson

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

* fix: updates chart url in mock resource

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>

---------

Signed-off-by: Amit Singh <singhamitch@outlook.com>
Signed-off-by: semmet95 <singhamitch@outlook.com>
Co-authored-by: Vishal Kumar <vishal210893@gmail.com>
This commit is contained in:
Amit Singh 2025-06-16 09:14:58 +05:30 committed by GitHub
parent 26123cf671
commit 4d6fa58c0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 146 additions and 79 deletions

7
go.mod
View File

@ -24,7 +24,7 @@ require (
github.com/fluxcd/source-controller/api v0.30.0 github.com/fluxcd/source-controller/api v0.30.0
github.com/form3tech-oss/jwt-go v3.2.5+incompatible github.com/form3tech-oss/jwt-go v3.2.5+incompatible
github.com/gdamore/tcell/v2 v2.6.0 github.com/gdamore/tcell/v2 v2.6.0
github.com/getkin/kin-openapi v0.118.0 github.com/getkin/kin-openapi v0.131.0
github.com/go-git/go-git/v5 v5.16.0 github.com/go-git/go-git/v5 v5.16.0
github.com/go-logr/logr v1.4.2 github.com/go-logr/logr v1.4.2
github.com/go-resty/resty/v2 v2.8.0 github.com/go-resty/resty/v2 v2.8.0
@ -197,7 +197,6 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect github.com/huandu/xstrings v1.4.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/yaml v0.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jellydator/ttlcache/v3 v3.0.1 // indirect github.com/jellydator/ttlcache/v3 v3.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect
@ -231,10 +230,12 @@ require (
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725 // indirect github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725 // indirect
github.com/perimeterx/marshmallow v1.1.4 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect

18
go.sum
View File

@ -319,8 +319,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg= github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y= github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y=
github.com/getkin/kin-openapi v0.118.0 h1:z43njxPmJ7TaPpMSCQb7PN0dEYno4tyBPQcrFdHoLuM= github.com/getkin/kin-openapi v0.131.0 h1:NO2UeHnFKRYhZ8wg6Nyh5Cq7dHk4suQQr72a4pMrDxE=
github.com/getkin/kin-openapi v0.118.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= github.com/getkin/kin-openapi v0.131.0/go.mod h1:3OlG51PCYNsPByuiMB0t4fjnNlIDnaEDsjiKUV8nL58=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@ -504,7 +504,6 @@ github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97Dwqy
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@ -582,8 +581,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc=
github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jellydator/ttlcache/v3 v3.0.1 h1:cHgCSMS7TdQcoprXnWUptJZzyFsqs18Lt8VVhRuZYVU= github.com/jellydator/ttlcache/v3 v3.0.1 h1:cHgCSMS7TdQcoprXnWUptJZzyFsqs18Lt8VVhRuZYVU=
@ -780,6 +777,10 @@ github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 h
github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28/go.mod h1:Mu8i0/DdplvnjwRbAYPsc8+LRR27n/mp8VWdkN10GzE= github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28/go.mod h1:Mu8i0/DdplvnjwRbAYPsc8+LRR27n/mp8VWdkN10GzE=
github.com/oam-dev/terraform-controller v0.8.0 h1:/881bAELCsceSj+Zh3Nsu8Ym5N7D5Ho0HsWzO+TDc1w= github.com/oam-dev/terraform-controller v0.8.0 h1:/881bAELCsceSj+Zh3Nsu8Ym5N7D5Ho0HsWzO+TDc1w=
github.com/oam-dev/terraform-controller v0.8.0/go.mod h1:ydc9iHjgLzwuWB+MlE2vRA8gOZsif0T4E2FL34K8CZ4= github.com/oam-dev/terraform-controller v0.8.0/go.mod h1:ydc9iHjgLzwuWB+MlE2vRA8gOZsif0T4E2FL34K8CZ4=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
@ -828,8 +829,8 @@ github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw= github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
@ -986,8 +987,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts= github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
@ -1535,7 +1534,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=

View File

@ -355,17 +355,17 @@ func (c CUE) ParsePropertiesToSchemaWithCueX(ctx context.Context, templateFieldP
// FixOpenAPISchema fixes tainted `description` filed, missing of title `field`. // FixOpenAPISchema fixes tainted `description` filed, missing of title `field`.
func FixOpenAPISchema(name string, schema *openapi3.Schema) { func FixOpenAPISchema(name string, schema *openapi3.Schema) {
t := schema.Type t := schema.Type
switch t { if t.Is(openapi3.TypeObject) {
case "object":
for k, v := range schema.Properties { for k, v := range schema.Properties {
s := v.Value s := v.Value
FixOpenAPISchema(k, s) FixOpenAPISchema(k, s)
} }
case "array": } else if t.Is(openapi3.TypeArray) {
if schema.Items != nil { if schema.Items != nil {
FixOpenAPISchema("", schema.Items.Value) FixOpenAPISchema("", schema.Items.Value)
} }
} }
if name != "" { if name != "" {
schema.Title = name schema.Title = name
} }

View File

@ -445,7 +445,11 @@ func (g *Generator) GenOpenAPISchema(val cue.Value) error {
return err return err
} }
g.completeOpenAPISchema(doc) err = g.completeOpenAPISchema(doc)
if err != nil {
return err
}
openapiSchema, err := doc.MarshalJSON() openapiSchema, err := doc.MarshalJSON()
g.openapiSchema = openapiSchema g.openapiSchema = openapiSchema
if g.meta.Verbose { if g.meta.Verbose {
@ -455,22 +459,31 @@ func (g *Generator) GenOpenAPISchema(val cue.Value) error {
return err return err
} }
func (g *Generator) completeOpenAPISchema(doc *openapi3.T) { func (g *Generator) completeOpenAPISchema(doc *openapi3.T) error {
for key, schema := range doc.Components.Schemas { for key, schema := range doc.Components.Schemas {
switch key { switch key {
case "parameter": case "parameter":
spec := g.meta.name + "-spec" spec := g.meta.name + "-spec"
schema.Value.Title = spec schema.Value.Title = spec
completeFreeFormSchema(schema) completeFreeFormSchema(schema)
completeSchema(key, schema)
err := completeSchema(key, schema)
if err != nil {
return err
}
doc.Components.Schemas[spec] = schema doc.Components.Schemas[spec] = schema
delete(doc.Components.Schemas, key) delete(doc.Components.Schemas, key)
case g.meta.name + "-spec": case g.meta.name + "-spec":
continue continue
default: default:
completeSchema(key, schema) err := completeSchema(key, schema)
if err != nil {
return err
}
} }
} }
return nil
} }
// GenerateCode will call openapi-generator to generate code and modify it // GenerateCode will call openapi-generator to generate code and modify it
@ -544,17 +557,17 @@ func (g *Generator) GenerateCode() (err error) {
func completeFreeFormSchema(schema *openapi3.SchemaRef) { func completeFreeFormSchema(schema *openapi3.SchemaRef) {
v := schema.Value v := schema.Value
if v.OneOf == nil && v.AnyOf == nil && v.AllOf == nil && v.Properties == nil { if v.OneOf == nil && v.AnyOf == nil && v.AllOf == nil && v.Properties == nil {
if v.Type == openapi3.TypeObject { if v.Type.Is(openapi3.TypeObject) {
schema.Value.AdditionalProperties = openapi3.AdditionalProperties{Schema: &openapi3.SchemaRef{ schema.Value.AdditionalProperties = openapi3.AdditionalProperties{Schema: &openapi3.SchemaRef{
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: openapi3.TypeObject, Type: &openapi3.Types{openapi3.TypeObject},
Nullable: true, Nullable: true,
}, },
}} }}
} else if v.Type == "string" { } else if v.Type.Is(openapi3.TypeString) {
schema.Value.AdditionalProperties = openapi3.AdditionalProperties{Schema: &openapi3.SchemaRef{ schema.Value.AdditionalProperties = openapi3.AdditionalProperties{Schema: &openapi3.SchemaRef{
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
}, },
}} }}
} }
@ -565,7 +578,7 @@ func completeFreeFormSchema(schema *openapi3.SchemaRef) {
// 1. move properties in the root schema to sub schema in OneOf. See https://github.com/OpenAPITools/openapi-generator/issues/14250 // 1. move properties in the root schema to sub schema in OneOf. See https://github.com/OpenAPITools/openapi-generator/issues/14250
// 2. move default value to sub schema in OneOf. // 2. move default value to sub schema in OneOf.
// 3. remove duplicated type in OneOf. // 3. remove duplicated type in OneOf.
func fixSchemaWithOneOf(schema *openapi3.SchemaRef) { func fixSchemaWithOneOf(schema *openapi3.SchemaRef) error {
var schemaNeedFix []*openapi3.Schema var schemaNeedFix []*openapi3.Schema
oneOf := schema.Value.OneOf oneOf := schema.Value.OneOf
@ -575,7 +588,11 @@ func fixSchemaWithOneOf(schema *openapi3.SchemaRef) {
defaultValue := schema.Value.Default defaultValue := schema.Value.Default
schema.Value.Default = nil schema.Value.Default = nil
for _, s := range oneOf { for _, s := range oneOf {
completeSchemas(s.Value.Properties) err := completeSchemas(s.Value.Properties)
if err != nil {
return err
}
if defaultValueMatchOneOfItem(s.Value, defaultValue) { if defaultValueMatchOneOfItem(s.Value, defaultValue) {
s.Value.Default = defaultValue s.Value.Default = defaultValue
} }
@ -585,19 +602,19 @@ func fixSchemaWithOneOf(schema *openapi3.SchemaRef) {
// 1. A non-ref sub-schema maybe have no properties and the needed properties is in the root schema. // 1. A non-ref sub-schema maybe have no properties and the needed properties is in the root schema.
// 2. A sub-schema maybe have no type and the needed type is in the root schema. // 2. A sub-schema maybe have no type and the needed type is in the root schema.
// In both cases, we need to complete the sub-schema with the properties or type in the root schema if any of them is missing. // In both cases, we need to complete the sub-schema with the properties or type in the root schema if any of them is missing.
if s.Value.Properties == nil || s.Value.Type == "" { if s.Value.Properties == nil || s.Value.Type.Is("") {
schemaNeedFix = append(schemaNeedFix, s.Value) schemaNeedFix = append(schemaNeedFix, s.Value)
} }
} }
if schemaNeedFix == nil { if schemaNeedFix == nil {
return // no non-ref schema found return nil // no non-ref schema found
} }
for _, s := range schemaNeedFix { for _, s := range schemaNeedFix {
if s.Properties == nil { if s.Properties == nil {
s.Properties = schema.Value.Properties s.Properties = schema.Value.Properties
} }
if s.Type == "" { if s.Type == nil || s.Type.Is("") {
s.Type = schema.Value.Type s.Type = schema.Value.Type
} }
} }
@ -605,13 +622,19 @@ func fixSchemaWithOneOf(schema *openapi3.SchemaRef) {
// remove duplicated type // remove duplicated type
for i, s := range oneOf { for i, s := range oneOf {
if s.Value.Type == "" { if s.Value.Type == nil || s.Value.Type.Is("") {
continue continue
} }
if _, ok := typeSet[s.Value.Type]; ok && s.Value.Type != openapi3.TypeObject {
jsonType, err := s.Value.Type.MarshalJSON()
if err != nil {
return fmt.Errorf("error while marshalling openapi schema type:%w", err)
}
if _, ok := typeSet[string(jsonType)]; ok && !s.Value.Type.Is(openapi3.TypeObject) {
duplicateIndex = append(duplicateIndex, i) duplicateIndex = append(duplicateIndex, i)
} else { } else {
typeSet[s.Value.Type] = struct{}{} typeSet[string(jsonType)] = struct{}{}
} }
} }
if len(duplicateIndex) > 0 { if len(duplicateIndex) > 0 {
@ -624,13 +647,14 @@ func fixSchemaWithOneOf(schema *openapi3.SchemaRef) {
schema.Value.OneOf = newRefs schema.Value.OneOf = newRefs
} }
return nil
} }
func completeSchema(key string, schema *openapi3.SchemaRef) { func completeSchema(key string, schema *openapi3.SchemaRef) error {
schema.Value.Title = key schema.Value.Title = key
if schema.Value.OneOf != nil { if schema.Value.OneOf != nil {
fixSchemaWithOneOf(schema) err := fixSchemaWithOneOf(schema)
return return err
} }
// allow all the fields to be empty to avoid this case: // allow all the fields to be empty to avoid this case:
@ -638,19 +662,30 @@ func completeSchema(key string, schema *openapi3.SchemaRef) {
// However, the empty value is not allowed on the server side when it is conflict with the default value in CUE. // However, the empty value is not allowed on the server side when it is conflict with the default value in CUE.
// schema.Value.Required = []string{} // schema.Value.Required = []string{}
switch schema.Value.Type { if schema.Value.Type.Is(openapi3.TypeObject) {
case openapi3.TypeObject: err := completeSchemas(schema.Value.Properties)
completeSchemas(schema.Value.Properties) if err != nil {
case openapi3.TypeArray: return err
completeSchema(key, schema.Value.Items) }
} else if schema.Value.Type.Is(openapi3.TypeArray) {
err := completeSchema(key, schema.Value.Items)
if err != nil {
return err
}
} }
return nil
} }
func completeSchemas(schemas openapi3.Schemas) { func completeSchemas(schemas openapi3.Schemas) error {
for k, schema := range schemas { for k, schema := range schemas {
completeSchema(k, schema) err := completeSchema(k, schema)
if err != nil {
return err
}
} }
return nil
} }
// NewModifiableGenerator returns a new Generator with modifiers // NewModifiableGenerator returns a new Generator with modifiers
@ -704,15 +739,15 @@ func (t CUEType) fit(schema *openapi3.Schema) bool {
openapiType := schema.Type openapiType := schema.Type
switch t { switch t {
case "string": case "string":
return openapiType == "string" return openapiType.Is(openapi3.TypeString)
case "integer": case "integer":
return openapiType == "integer" || openapiType == "number" return openapiType.Is(openapi3.TypeInteger) || openapiType.Is(openapi3.TypeNumber)
case "number": case "number":
return openapiType == "number" return openapiType.Is(openapi3.TypeNumber)
case "boolean": case "boolean":
return openapiType == "boolean" return openapiType.Is(openapi3.TypeBoolean)
case "array": case "array":
return openapiType == "array" return openapiType.Is(openapi3.TypeArray)
default: default:
return false return false
} }

View File

@ -151,18 +151,19 @@ var _ = Describe("FixSchemaWithOneAnyAllOf", func() {
OneOf: openapi3.SchemaRefs{ OneOf: openapi3.SchemaRefs{
{ {
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "number", Type: &openapi3.Types{"number"},
}, },
}, },
{ {
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
}, },
}, },
}, },
}, },
} }
fixSchemaWithOneOf(schema) err := fixSchemaWithOneOf(schema)
Expect(err).To(BeNil())
Expect(schema.Value.OneOf[0].Value.Default).To(Equal(1)) Expect(schema.Value.OneOf[0].Value.Default).To(Equal(1))
Expect(schema.Value.OneOf[1].Value.Default).To(BeNil()) Expect(schema.Value.OneOf[1].Value.Default).To(BeNil())
@ -174,34 +175,35 @@ var _ = Describe("FixSchemaWithOneAnyAllOf", func() {
By(`image: language | string`) By(`image: language | string`)
schema = &openapi3.SchemaRef{ schema = &openapi3.SchemaRef{
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
Title: "image", Title: "image",
OneOf: openapi3.SchemaRefs{ OneOf: openapi3.SchemaRefs{
{ {
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
Enum: []interface{}{"go", "java", "python", "node", "ruby"}, Enum: []interface{}{"go", "java", "python", "node", "ruby"},
}, },
}, },
{ {
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
}, },
}, },
}, },
}, },
} }
fixSchemaWithOneOf(schema) err := fixSchemaWithOneOf(schema)
Expect(err).To(BeNil())
Expect(schema.Value.OneOf).To(HaveLen(1)) Expect(schema.Value.OneOf).To(HaveLen(1))
Expect(schema.Value.OneOf[0].Value.Type).To(Equal("string")) Expect(schema.Value.OneOf[0].Value.Type).To(Equal(&openapi3.Types{"string"}))
Expect(schema.Value.OneOf[0].Value.Enum).To(Equal([]interface{}{"go", "java", "python", "node", "ruby"})) Expect(schema.Value.OneOf[0].Value.Enum).To(Equal([]interface{}{"go", "java", "python", "node", "ruby"}))
}) })
It("should both move type and remove duplicated type in oneOf", func() { It("should both move type and remove duplicated type in oneOf", func() {
schema = &openapi3.SchemaRef{ schema = &openapi3.SchemaRef{
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
Title: "image", Title: "image",
OneOf: openapi3.SchemaRefs{ OneOf: openapi3.SchemaRefs{
{ {
@ -211,16 +213,17 @@ var _ = Describe("FixSchemaWithOneAnyAllOf", func() {
}, },
{ {
Value: &openapi3.Schema{ Value: &openapi3.Schema{
Type: "string", Type: &openapi3.Types{"string"},
}, },
}, },
}, },
}, },
} }
fixSchemaWithOneOf(schema) err := fixSchemaWithOneOf(schema)
Expect(err).To(BeNil())
Expect(schema.Value.OneOf).To(HaveLen(1)) Expect(schema.Value.OneOf).To(HaveLen(1))
Expect(schema.Value.OneOf[0].Value.Type).To(Equal("string")) Expect(schema.Value.OneOf[0].Value.Type).To(Equal(&openapi3.Types{"string"}))
Expect(schema.Value.OneOf[0].Value.Enum).To(Equal([]interface{}{"go", "java", "python", "node", "ruby"})) Expect(schema.Value.OneOf[0].Value.Enum).To(Equal([]interface{}{"go", "java", "python", "node", "ruby"}))
}) })
}) })
@ -311,7 +314,7 @@ var _ = Describe("type fit", func() {
var schema *openapi3.Schema var schema *openapi3.Schema
BeforeEach(func() { BeforeEach(func() {
schema = &openapi3.Schema{Type: "string"} schema = &openapi3.Schema{Type: &openapi3.Types{"string"}}
}) })
var testCases = []struct { var testCases = []struct {
@ -333,7 +336,7 @@ var _ = Describe("type fit", func() {
It("should return whether the CUEType fits the schema type or not", func() { It("should return whether the CUEType fits the schema type or not", func() {
for _, tc := range testCases { for _, tc := range testCases {
schema.Type = tc.schemaType schema.Type = &openapi3.Types{tc.schemaType}
result := tc.cueType.fit(schema) result := tc.cueType.fit(schema)
Expect(result).To(Equal(tc.expectedFit), tc.name) Expect(result).To(Equal(tc.expectedFit), tc.name)
} }

View File

@ -93,17 +93,18 @@ func ConvertOpenAPISchema2SwaggerObject(data []byte) (*openapi3.Schema, error) {
// FixOpenAPISchema fixes tainted `description` filed, missing of title `field`. // FixOpenAPISchema fixes tainted `description` filed, missing of title `field`.
func FixOpenAPISchema(name string, schema *openapi3.Schema) { func FixOpenAPISchema(name string, schema *openapi3.Schema) {
t := schema.Type t := schema.Type
switch t {
case "object": if t.Is(openapi3.TypeObject) {
for k, v := range schema.Properties { for k, v := range schema.Properties {
s := v.Value s := v.Value
FixOpenAPISchema(k, s) FixOpenAPISchema(k, s)
} }
case "array": } else if t.Is(openapi3.TypeArray) {
if schema.Items != nil { if schema.Items != nil {
FixOpenAPISchema("", schema.Items.Value) FixOpenAPISchema("", schema.Items.Value)
} }
} }
if name != "" { if name != "" {
schema.Title = name schema.Title = name
} }

View File

@ -84,7 +84,7 @@ var _ = Describe("Test the config provider", func() {
Namespace: "default", Namespace: "default",
Template: "default/test-image-registry", Template: "default/test-image-registry",
Config: map[string]interface{}{ Config: map[string]interface{}{
"registry": "hub.kubevela.net", "registry": "ghcr.io/kubevela",
}, },
}, },
RuntimeParams: oamprovidertypes.RuntimeParams{ RuntimeParams: oamprovidertypes.RuntimeParams{
@ -133,7 +133,7 @@ var _ = Describe("Test the config provider", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
contents := res.Returns.Configs contents := res.Returns.Configs
Expect(len(contents)).To(Equal(1)) Expect(len(contents)).To(Equal(1))
Expect(contents[0]["config"].(map[string]interface{})["registry"]).To(Equal("hub.kubevela.net")) Expect(contents[0]["config"].(map[string]interface{})["registry"]).To(Equal("ghcr.io/kubevela"))
}) })
It("test reading the config", func() { It("test reading the config", func() {
@ -148,7 +148,7 @@ var _ = Describe("Test the config provider", func() {
}, },
}) })
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(res.Returns.Config["registry"]).To(Equal("hub.kubevela.net")) Expect(res.Returns.Config["registry"]).To(Equal("ghcr.io/kubevela"))
}) })
It("test deleting the config", func() { It("test deleting the config", func() {

View File

@ -84,7 +84,7 @@ var _ = Describe("Test the config provider", func() {
Namespace: "default", Namespace: "default",
Template: "default/test-image-registry", Template: "default/test-image-registry",
Config: map[string]interface{}{ Config: map[string]interface{}{
"registry": "hub.kubevela.net", "registry": "ghcr.io/kubevela",
}, },
}, },
RuntimeParams: oamprovidertypes.RuntimeParams{ RuntimeParams: oamprovidertypes.RuntimeParams{
@ -133,7 +133,7 @@ var _ = Describe("Test the config provider", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
contents := res.Configs contents := res.Configs
Expect(len(contents)).To(Equal(1)) Expect(len(contents)).To(Equal(1))
Expect(contents[0]["config"].(map[string]interface{})["registry"]).To(Equal("hub.kubevela.net")) Expect(contents[0]["config"].(map[string]interface{})["registry"]).To(Equal("ghcr.io/kubevela"))
}) })
It("test reading the config", func() { It("test reading the config", func() {
@ -148,7 +148,7 @@ var _ = Describe("Test the config provider", func() {
}, },
}) })
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(res.Config["registry"]).To(Equal("hub.kubevela.net")) Expect(res.Config["registry"]).To(Equal("ghcr.io/kubevela"))
}) })
It("test deleting the config", func() { It("test deleting the config", func() {

View File

@ -913,7 +913,7 @@ func printSchema(ref *openapi3.Schema, currentParams map[string]interface{}, ind
// Object type param, we will get inside the object. // Object type param, we will get inside the object.
// To show what's inside nested objects. // To show what's inside nested objects.
if propValue.Value.Type == "object" { if propValue.Value.Type.Is(openapi3.TypeObject) {
nestedParam := make(map[string]interface{}) nestedParam := make(map[string]interface{})
if hasParam { if hasParam {
nestedParam = currentParams[propKey].(map[string]interface{}) nestedParam = currentParams[propKey].(map[string]interface{})

View File

@ -19,6 +19,7 @@ package docgen
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"strconv"
"strings" "strings"
"github.com/getkin/kin-openapi/openapi3" "github.com/getkin/kin-openapi/openapi3"
@ -45,9 +46,20 @@ func GenerateConsoleDocument(title string, schema *openapi3.Schema) (string, err
for _, enum := range subSchema.Value.Enum { for _, enum := range subSchema.Value.Enum {
options += fmt.Sprintf("%v", enum) options += fmt.Sprintf("%v", enum)
} }
jsonType, err := subSchema.Value.Type.MarshalJSON()
if err != nil {
return "", fmt.Errorf("error while marshalling openapi schema type:%w", err)
}
typeStr, err := strconv.Unquote(string(jsonType))
if err != nil {
return "", fmt.Errorf("error while unquoting opai schema type:%w", err)
}
propertiesTable.Append([]string{ propertiesTable.Append([]string{
name, name,
subSchema.Value.Type, typeStr,
subSchema.Value.Description, subSchema.Value.Description,
fmt.Sprintf("%t", strings.Contains(strings.Join(schema.Required, "/"), subSchema.Value.Title)), fmt.Sprintf("%t", strings.Contains(strings.Join(schema.Required, "/"), subSchema.Value.Title)),
options, options,

View File

@ -636,21 +636,31 @@ func ParseLocalFile(localFilePath string, c common.Args) (*types.Capability, err
} }
// WalkParameterSchema will extract properties from *openapi3.Schema // WalkParameterSchema will extract properties from *openapi3.Schema
func WalkParameterSchema(parameters *openapi3.Schema, name string, depth int) { func WalkParameterSchema(parameters *openapi3.Schema, name string, depth int) error {
if parameters == nil { if parameters == nil {
return return nil
} }
var schemas []CommonSchema var schemas []CommonSchema
var commonParameters []ReferenceParameter var commonParameters []ReferenceParameter
for k, v := range parameters.Properties { for k, v := range parameters.Properties {
jsonType, err := v.Value.Type.MarshalJSON()
if err != nil {
return fmt.Errorf("error while marshalling openapi schema type:%w", err)
}
typeStr, err := strconv.Unquote(string(jsonType))
if err != nil {
return fmt.Errorf("error while unquoting opai schema type:%w", err)
}
p := ReferenceParameter{ p := ReferenceParameter{
Parameter: types.Parameter{ Parameter: types.Parameter{
Name: k, Name: k,
Default: v.Value.Default, Default: v.Value.Default,
Usage: v.Value.Description, Usage: v.Value.Description,
JSONType: v.Value.Type, JSONType: typeStr,
}, },
PrintableType: v.Value.Type, PrintableType: typeStr,
} }
required := false required := false
for _, requiredType := range parameters.Required { for _, requiredType := range parameters.Required {
@ -660,7 +670,7 @@ func WalkParameterSchema(parameters *openapi3.Schema, name string, depth int) {
} }
} }
p.Required = required p.Required = required
if v.Value.Type == "object" { if v.Value.Type.Is(openapi3.TypeObject) {
if v.Value.Properties != nil { if v.Value.Properties != nil {
schemas = append(schemas, CommonSchema{ schemas = append(schemas, CommonSchema{
Name: k, Name: k,
@ -679,8 +689,13 @@ func WalkParameterSchema(parameters *openapi3.Schema, name string, depth int) {
}) })
for _, schema := range schemas { for _, schema := range schemas {
WalkParameterSchema(schema.Schemas, schema.Name, depth+1) err := WalkParameterSchema(schema.Schemas, schema.Name, depth+1)
if err != nil {
return err
}
} }
return nil
} }
// GetBaseResourceKinds helps get resource.group string of components' base resource // GetBaseResourceKinds helps get resource.group string of components' base resource

View File

@ -248,7 +248,9 @@ func TestWalkParameterSchema(t *testing.T) {
swagger, err := openapi3.NewLoader().LoadFromData(json.RawMessage(parameterJSON)) swagger, err := openapi3.NewLoader().LoadFromData(json.RawMessage(parameterJSON))
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
parameters := swagger.Components.Schemas["parameter"].Value parameters := swagger.Components.Schemas["parameter"].Value
WalkParameterSchema(parameters, Specification, 0) err = WalkParameterSchema(parameters, Specification, 0)
assert.Nil(t, err)
refs := make(map[string]map[string]ReferenceParameter) refs := make(map[string]map[string]ReferenceParameter)
for _, items := range commonRefs { for _, items := range commonRefs {
refs[items.Name] = make(map[string]ReferenceParameter) refs[items.Name] = make(map[string]ReferenceParameter)