-
Notifications
You must be signed in to change notification settings - Fork 0
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
Requirements #1
Comments
The duplication in the generated code results in two problems:
The Xero APIs generated like this are going to run into the multiple tens of thousands of lines. It is going to break. The fix will be to move repeated blocks into separate functions. |
@bradydan the link above is a live API call to the // A plain PSR-18 client
$baseClient = Http\Factory\Discovery\HttpClient::client();
// Decorated (wrapped) with our authorisation layer for Xero:
$httpClient = $xeroPartnerClient::getClient($baseClient);
// Instantiate the generated API class with our decorated PSR-18 client:
$accountingApi= new Client\Api\AccountingApi($httpClient);
// Call the endpoint we need to access. This one takes no parameters.
$response = $accountingApi->getOrganisations();
// Look at the result:
dump($response); The first three steps would be wrapped up into a framework service, so the accountingApi is simply created by the service whenever we need it and without fiddling on with those HTTP client layers. So we just say, "hey client, give me the stuff", and we have them through all the invisible layers of requests and stuff. All the API stuff is hidden away, and we can then focus on the business rules of the code. That's what we are aiming at. |
William’s GitHub user is @wing328 |
OMG, the Xero Accounting API class is 57k lines line. 57,385 lines. One class. That's just crazy. It is probably usable, but we'll try to make some de-duplication gains where we can (but if it works, it won't be the focus). There is another 51k lines of code making up the 109 model classes too. Now imagine writing that code by hand - over 100,000 lines. I don't envy those even writing the OpenAPI spec. I'm NOT going to run the OpenBanking spec through this quite yet. That will be multiple times bigger. |
Wow. Now we get to see what a mammoth job their move to OpenAPI has been. Let’s hope the code is usable. The Xero accounting API seems to contain most of the functionality to do with payments and invoices (and more), so I’d expect their other APIs to be much smaller. |
The bankfeeds API is an order of magnitude smaller; about tenth the size. |
The It treats a string as JSON to decode and build into objects. It treats The main point though is that a PSR-18 client will always return a Looking at the file stream handling, if the response has a content disposition filename, then the intermediate file is created in the configured temporary area with the same name. If you have multiple requests being performed at once, to files of the same name, then these requests will start overwriting each other. I have not tested that, but this is just from observation. However, the deserialiser is not actually given any of the headers, so the content disposition is nor checked. I think this needs to go to a new issue to refactor deserialisation. |
Some traits would be nice for functions that can be shared between multiple API classes, such as helper functions. Can additional templates and generated files be added to the template list without changing the Java generation logic? I've read that it can't, but it's worth exploring. Putting that code into partial templates should work though, and would be a step in that direction. |
@wing328 This repo is now public. Please can you take a look at Jason’s comments above? |
Based on the
php
generator templates, these are the main differences:These would only be used at run-time if authentication details have been passed in,
otherwise the assumption is made that authentication is already built into the supplied PSR-18 http client. See issue Strip out Authentication #2
with*()
methods. This is opinionated, but is where we would like to go.__get()
methods to access the properties. Needing to use individual getters for every property is not so easy.get_data()
method (with its underlying Symfony support) can walk the nested response objects and models.The text was updated successfully, but these errors were encountered: