Skip to content

Comments

feat(parser): default required fields#60

Open
eduhdev12 wants to merge 6 commits intoparvez3019:mainfrom
eduhdev12:feature/required-default
Open

feat(parser): default required fields#60
eduhdev12 wants to merge 6 commits intoparvez3019:mainfrom
eduhdev12:feature/required-default

Conversation

@eduhdev12
Copy link

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

@qequ
Copy link
Collaborator

qequ commented Apr 9, 2025

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

@eduhdev12
Copy link
Author

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

@qequ
Copy link
Collaborator

qequ commented Apr 24, 2025

@eduhdev12 failed tests please fix the tests

@eduhdev12
Copy link
Author

@eduhdev12 failed tests please fix the tests

I hope now it's passing it :)

@parvez3019
Copy link
Owner

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)

@eduhdev12
Copy link
Author

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

@bivashy
Copy link

bivashy commented Jun 18, 2025

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?

@eduhdev12
Copy link
Author

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

@parvez3019
Copy link
Owner

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

@eduhdev12
Copy link
Author

?       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

@bivashy
Copy link

bivashy commented Jun 19, 2025

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.

@eduhdev12
Copy link
Author

@parvez3019 any help here with the CI to get this released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants