Skip to content

Commit

Permalink
Merge pull request #21 from golemcloud/vigoo/type-mappings
Browse files Browse the repository at this point in the history
Ability to provide mappings to existing types
  • Loading branch information
vigoo authored Oct 9, 2024
2 parents 7dddf1d + 858e9bc commit c195cda
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 181 deletions.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -68,7 +69,10 @@ pub fn gen(
version: &str,
overwrite_cargo: bool,
disable_clippy: bool,
mapping: &[(&str, &str)],
) -> Result<()> {
let mapping: HashMap<&str, &str> = HashMap::from_iter(mapping.iter().cloned());

let open_api = merge_all_openapi_specs(openapi_specs)?;

let src = target.join("src");
Expand Down Expand Up @@ -113,7 +117,7 @@ pub fn gen(
for ref_str in ref_cache.refs {
if !known_refs.refs.contains(&ref_str) {
let model_file =
rust::model_gen::model_gen(&ref_str, &open_api, &mut next_ref_cache)?;
rust::model_gen::model_gen(&ref_str, &open_api, &mapping, &mut next_ref_cache)?;
std::fs::write(model.join(model_file.def.name.file_name()), model_file.code)
.unwrap();
models.push(model_file.def);
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fn main() {
&args.client_version,
true,
false,
&[],
)
.unwrap();
}
Expand Down
Loading

0 comments on commit c195cda

Please sign in to comment.