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

Fails on a complex YAML file #1

Open
oravecz opened this issue Dec 22, 2020 · 2 comments
Open

Fails on a complex YAML file #1

oravecz opened this issue Dec 22, 2020 · 2 comments

Comments

@oravecz
Copy link

oravecz commented Dec 22, 2020

The sample yaml in the README file works fine, but when I run the code generator against the rather large YAML file found as part of the Open Banking API, it crashes.

% pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script completed, took 529ms
[INFO] Reading cached asset graph completed, took 186ms
[INFO] Checking for updates since last build completed, took 1.6s
[SEVERE] openapi_code_builder:openapi_code_builder on lib/account-info.openapi.yaml:

Converting object to an encodable object failed: Instance of 'YamlMap'
[INFO] Running build completed, took 483ms
[INFO] Caching finalized dependency graph completed, took 53ms
[SEVERE] Failed after 559ms

The YAML file I am using can be found at this URL:
https://raw.githubusercontent.com/OpenBankingUK/read-write-api-specs/master/dist/openapi/account-info-openapi.yaml

@chandu0101
Copy link

code is failing at

return json.decode(json.encode(tmp)) as Map<String, dynamic>;

 final dynamic tmp = loadYaml(source);
    final content = json.encode(tmp)); // error 

this should be fixed in yaml package itself! , or this lib should support json file inputs so that user can use service like https://onlineyamltools.com/convert-yaml-to-json , to convert to json and then use it as input.

@hpoul
Copy link
Owner

hpoul commented Aug 7, 2021

sorry for the late response.. but imho that yaml schema is not valid..

The keys (status codes) of responses must be strings.. because in JSON all keys must be strings. This is probably the reason why json.encode jokes at this point.

Screen Shot 2021-08-07 at 21 14 13

Although to be honest, I've developed the generator to generate a simple server/client pair, not necessary generate the client for existing complicated schemas.. but i'll see if I can get it to work.. still interesting.. But I think the best use case is using it for client AND server.. (there are a lot of client side dart generators already out there)

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

No branches or pull requests

3 participants