Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api] /format endpoint returns JSON-encoded BAI2 file #100

Merged
merged 7 commits into from
Mar 19, 2024

Conversation

wokkaflokka
Copy link
Collaborator

This change proposes a new endpoint for the BAI2 server that validates a BAI2 file and returns a JSON structure of the file. The returned JSON matches the structure that this library uses internally to represent a BAI2 file.

api/api.yaml Outdated
content:
application/json:
schema:
type: object
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return type could be strongly typed, if preferred.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, can we reuse the OpenAPI models ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamdecaf sure thing.

I pushed two subsequent commits.

The first fixes the build with respect to lint, etc.

The second adds OpenAPI models for this endpoint. I didn't see any existing models and took a first pass here -- please let me know what changes you'd like to see from here.

There seems to be an active GH outage that is currently these latest commits showing up (2024-03-12 7:45 PM CST) but I'm expecting a new build to trigger eventually.


suite.testServer.ServeHTTP(recorder, request)
assert.Equal(suite.T(), http.StatusOK, recorder.Code)
assert.Equal(suite.T(), recorder.Body.String(), `{"sender":"0004","receiver":"12345","fileCreatedDate":"060321","fileCreatedTime":"0829","fileIdNumber":"001","physicalRecordLength":80,"blockSize":1,"versionNumber":2,"fileControlTotal":"+00000000001280000","numberOfGroups":1,"numberOfRecords":27,"Groups":[{"receiver":"12345","originator":"0004","groupStatus":1,"asOfDate":"060317","currencyCode":"CAD","groupControlTotal":"+00000000001280000","numberOfAccounts":2,"numberOfRecords":25,"Accounts":[{"accountNumber":"10200123456","currencyCode":"CAD","summaries":[{"TypeCode":"040","Amount":"+000000000000","ItemCount":0,"FundsType":{}},{"TypeCode":"045","Amount":"+000000000000","ItemCount":0,"FundsType":{}},{"TypeCode":"100","Amount":"000000000208500","ItemCount":3,"FundsType":{"type_code":"V","date":"060316"}},{"TypeCode":"400","Amount":"000000000208500","ItemCount":8,"FundsType":{"type_code":"V","date":"060316"}}],"accountControlTotal":"+00000000000834000","numberRecords":14,"Details":[{"TypeCode":"409","Amount":"000000000002500","FundsType":{"type_code":"V","date":"060316"},"BankReferenceNumber":"","CustomerReferenceNumber":"","Text":"RETURNED CHEQUE "}]},{"accountNumber":"10200123456","currencyCode":"CAD","summaries":[{"TypeCode":"040","Amount":"+000000000000","ItemCount":0,"FundsType":{}},{"TypeCode":"045","Amount":"+000000000000","ItemCount":0,"FundsType":{}},{"TypeCode":"100","Amount":"000000000111500","ItemCount":2,"FundsType":{"type_code":"V","date":"060317"}},{"TypeCode":"400","Amount":"000000000111500","ItemCount":4,"FundsType":{"type_code":"V","date":"060317"}}],"accountControlTotal":"+00000000000446000","numberRecords":9,"Details":[{"TypeCode":"108","Amount":"000000000011500","FundsType":{"type_code":"V","date":"060317"},"BankReferenceNumber":"","CustomerReferenceNumber":"","Text":"TFR 1020 0345678 "}]}]}]}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion will require an update if/when #101 is promoted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#101 is merged, can you update this test case?

@adamdecaf
Copy link
Member

The build failure is fixed in newer OpenAPI versions. If we're going to release a bigger change I'm okay forcing a newer openapi-generator as well. Thoughts?

@wokkaflokka
Copy link
Collaborator Author

@adamdecaf I am fine making that upgrade here if you are.

@wokkaflokka
Copy link
Collaborator Author

@adamdecaf I updated OpenAPI to 7.4.0.

The generator generated a new test file named pkg/client/test/api_bai2_files_test.go that I manually deleted from source. I looked for an option to disable generating this test for now, but didn't find one, so would expect this to come back on next generation.

Keeping and running the test would be fine, but it includes a templated Git URL that requires additional configuration / was leading to test failure locally.

@wokkaflokka wokkaflokka merged commit fffb0e4 into moov-io:master Mar 19, 2024
5 checks passed
@wokkaflokka wokkaflokka deleted the format branch March 19, 2024 23:04
@adamdecaf
Copy link
Member

Sounds good. Thanks!

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.

2 participants