go-swagger3
go-swagger3 copied to clipboard
feat(parser): default required fields
New CLI Flag to set all the fields from a struct by default to true
Hi, thanks for the PR. can you add some tests and update the documentation with what the flag does ?
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 failed tests please fix the tests
@eduhdev12 failed tests please fix the tests
I hope now it's passing it :)
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)
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
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?
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
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
? 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
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.jsonin 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.