go-swagger3 icon indicating copy to clipboard operation
go-swagger3 copied to clipboard

feat(parser): default required fields

Open eduhdev12 opened this issue 7 months ago • 11 comments

New CLI Flag to set all the fields from a struct by default to true

eduhdev12 avatar Apr 09 '25 11:04 eduhdev12

Hi, thanks for the PR. can you add some tests and update the documentation with what the flag does ?

qequ avatar Apr 09 '25 15:04 qequ

Hi, thanks for the PR. can you add some tests and update the documentation with what the flag does ?

Done! Let me know if I missed anything

eduhdev12 avatar Apr 23 '25 08:04 eduhdev12

@eduhdev12 failed tests please fix the tests

qequ avatar Apr 24 '25 14:04 qequ

@eduhdev12 failed tests please fix the tests

I hope now it's passing it :)

eduhdev12 avatar Apr 24 '25 15:04 eduhdev12

Hi

Test_GenerateExpectedSpecWithDefaultRequired is failing.

=== RUN   Test_GenerateExpectedSpecWithDefaultRequired
time="2025-04-26T10:15:16Z" level=info msg="Parsing Initialized"
time="2025-04-26T10:15:16Z" level=info msg="Parsing Info ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing Modules ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing GoMod Info ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing APIs ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing Completed ..."
time="2025-04-26T10:15:16Z" level=info msg="Writing to open api object file ..."
    app_test.go:[49](https://github.com/parvez3019/go-swagger3/actions/runs/14667147170/job/41202045726?pr=60#step:4:50): 
        	Error Trace:	app_test.go:49
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : 2
        	Test:       	Test_GenerateExpectedSpecWithDefaultRequired
--- FAIL: Test_GenerateExpectedSpecWithDefaultRequired (0.00s)

parvez3019 avatar Apr 26 '25 10:04 parvez3019

Hi

Test_GenerateExpectedSpecWithDefaultRequired is failing.

=== RUN   Test_GenerateExpectedSpecWithDefaultRequired
time="2025-04-26T10:15:16Z" level=info msg="Parsing Initialized"
time="2025-04-26T10:15:16Z" level=info msg="Parsing Info ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing Modules ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing GoMod Info ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing APIs ..."
time="2025-04-26T10:15:16Z" level=info msg="Parsing Completed ..."
time="2025-04-26T10:15:16Z" level=info msg="Writing to open api object file ..."
    app_test.go:[49](https://github.com/parvez3019/go-swagger3/actions/runs/14667147170/job/41202045726?pr=60#step:4:50): 
        	Error Trace:	app_test.go:49
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : 2
        	Test:       	Test_GenerateExpectedSpecWithDefaultRequired
--- FAIL: Test_GenerateExpectedSpecWithDefaultRequired (0.00s)

I don't know why, because on local it's passing without any error

eduhdev12 avatar Apr 27 '25 08:04 eduhdev12

I don't know why, because on local it's passing without any error

Commit test_data/spec/actual.json, because currently it is missing?

bivashy avatar Jun 18 '25 05:06 bivashy

I don't know why, because on local it's passing without any error

Commit test_data/spec/actual.json, because currently it is missing?

integration_test/test_data/spec/actual.json is inside .gitignore and created at test runtime

eduhdev12 avatar Jun 18 '25 06:06 eduhdev12

Hi Actual.json is the output swagger file that's get generated when test runs hence that doesn't need to committed

All we need to make sure we have correct setup and expected json file

parvez3019 avatar Jun 19 '25 05:06 parvez3019

?       github.com/parvez3019/go-swagger3       [no test files]
?       github.com/parvez3019/go-swagger3/app   [no test files]
=== RUN   Test_ShouldGenerateExpectedSpec
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Initialized"
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Info ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Modules ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing GoMod Info ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing APIs ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Completed ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Writing to open api object file ..."
--- PASS: Test_ShouldGenerateExpectedSpec (0.01s)
=== RUN   Test_GenerateExpectedSpecWithPkg
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Initialized"
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Info ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Modules ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing GoMod Info ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing APIs ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Completed ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Writing to open api object file ..."
--- PASS: Test_GenerateExpectedSpecWithPkg (0.00s)
=== RUN   Test_GenerateExpectedSpecWithDefaultRequired
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Initialized"
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Info ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Modules ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing GoMod Info ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing APIs ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Parsing Completed ..."
time="2025-06-19T10:50:25+03:00" level=info msg="Writing to open api object file ..."
--- PASS: Test_GenerateExpectedSpecWithDefaultRequired (0.00s)
PASS
ok      github.com/parvez3019/go-swagger3/integration_test      0.215s
?       github.com/parvez3019/go-swagger3/logger        [no test files]
?       github.com/parvez3019/go-swagger3/openApi3Schema        [no test files]
?       github.com/parvez3019/go-swagger3/parser        [no test files]
=== RUN   Test_ParseHeaderParameters
=== RUN   Test_ParseHeaderParameters/Should_return_header_parameters
=== RUN   Test_ParseHeaderParameters/Should_return_error_when_failed_parsing_schema_object
=== RUN   Test_ParseHeaderParameters/Should_return_error_when_schema_properties_are_nil
=== RUN   Test_ParseHeaderParameters/Should_return_error_when_fails_casting_schema_value_to_schema_object
--- PASS: Test_ParseHeaderParameters (0.00s)
    --- PASS: Test_ParseHeaderParameters/Should_return_header_parameters (0.00s)
    --- PASS: Test_ParseHeaderParameters/Should_return_error_when_failed_parsing_schema_object (0.00s)
    --- PASS: Test_ParseHeaderParameters/Should_return_error_when_schema_properties_are_nil (0.00s)
    --- PASS: Test_ParseHeaderParameters/Should_return_error_when_fails_casting_schema_value_to_schema_object (0.00s)
PASS
ok      github.com/parvez3019/go-swagger3/parser/apis   0.340s
?       github.com/parvez3019/go-swagger3/parser/gomod  [no test files]
?       github.com/parvez3019/go-swagger3/parser/info   [no test files]
?       github.com/parvez3019/go-swagger3/parser/model  [no test files]
?       github.com/parvez3019/go-swagger3/parser/module [no test files]
=== RUN   Test_ParseHeader
=== RUN   Test_ParseHeader/Should_add_parameters_with_ref
=== RUN   Test_ParseHeader/Should_return_error_if_fails_parsing_the_schema
=== RUN   Test_ParseHeader/Should_return_error_schema_properties_are_nil
--- PASS: Test_ParseHeader (0.00s)
    --- PASS: Test_ParseHeader/Should_add_parameters_with_ref (0.00s)
    --- PASS: Test_ParseHeader/Should_return_error_if_fails_parsing_the_schema (0.00s)
    --- PASS: Test_ParseHeader/Should_return_error_schema_properties_are_nil (0.00s)
PASS
ok      github.com/parvez3019/go-swagger3/parser/operations     0.498s
?       github.com/parvez3019/go-swagger3/parser/schema [no test files]
?       github.com/parvez3019/go-swagger3/parser/schema/mocks   [no test files]
?       github.com/parvez3019/go-swagger3/parser/utils  [no test files]
?       github.com/parvez3019/go-swagger3/writer        [no test files]

Without having any changes from the last commit, here is the proof that test is passing for me, I have no idea what's the output difference in github workflow, maybe @parvez3019 can help with a little debug or log the actual.json in workflow to fix it

eduhdev12 avatar Jun 19 '25 08:06 eduhdev12

Without having any changes from the last commit, here is the proof that test is passing for me, I have no idea what's the output difference in github workflow, maybe @parvez3019 can help with a little debug or log the actual.json in workflow to fix it

I ran CI (test) in my GitHub repository, and it passed successfully. See: https://github.com/bivashy/go-swagger3/actions/runs/15755387272/job/44409563484. I included the last "chore: debug print" commit, so you can see the output.

bivashy avatar Jun 19 '25 10:06 bivashy