How to add 2 openapi generated folder to flutter / dart?

105 views Asked by At

I have 2 API's I need to integrate my flutter application with, both have swagger and both i generate with OpenAPI. I have one generated code in apifolder the other in api2.

Now my pubspec.yaml can handle only 1 path for the generated code like below:

openapi: 
    path: ./api/

How would i add a second path?

This wouldn't work due to uniqueness:

openapi: 
    path: ./api/
    path: ./api2/

Can i do it like:

openapi_01: 
    path: ./api/
openapi_02: 
    path: ./api2/

And inside the pubspec.yaml of each i define the identifier? like below:

name: openapi_01
version: 1.0.0
description: OpenAPI API client
homepage: homepage
1

There are 1 answers

0
Cyber On

I found the fix.

I use a bash script to generate the openapi folder, and now i have added additional properties to rename it:

openapi-generator generate -g dart-dio -i https://urls-to-api-json -o "$(pwd)/api/foldername" --additional-properties=pubName=pubspec_name_here

This will generate the file and the library in a format i need it like pubspec_name_here.dart as i needed.