Skip to content

Commit c195cda

Browse files
authored
Merge pull request #21 from golemcloud/vigoo/type-mappings
Ability to provide mappings to existing types
2 parents 7dddf1d + 858e9bc commit c195cda

File tree

3 files changed

+191
-181
lines changed

3 files changed

+191
-181
lines changed

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use std::collections::HashMap;
1516
use std::fs::File;
1617
use std::io::BufReader;
1718
use std::path::{Path, PathBuf};
@@ -68,7 +69,10 @@ pub fn gen(
6869
version: &str,
6970
overwrite_cargo: bool,
7071
disable_clippy: bool,
72+
mapping: &[(&str, &str)],
7173
) -> Result<()> {
74+
let mapping: HashMap<&str, &str> = HashMap::from_iter(mapping.iter().cloned());
75+
7276
let open_api = merge_all_openapi_specs(openapi_specs)?;
7377

7478
let src = target.join("src");
@@ -113,7 +117,7 @@ pub fn gen(
113117
for ref_str in ref_cache.refs {
114118
if !known_refs.refs.contains(&ref_str) {
115119
let model_file =
116-
rust::model_gen::model_gen(&ref_str, &open_api, &mut next_ref_cache)?;
120+
rust::model_gen::model_gen(&ref_str, &open_api, &mapping, &mut next_ref_cache)?;
117121
std::fs::write(model.join(model_file.def.name.file_name()), model_file.code)
118122
.unwrap();
119123
models.push(model_file.def);

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fn main() {
6464
&args.client_version,
6565
true,
6666
false,
67+
&[],
6768
)
6869
.unwrap();
6970
}

0 commit comments

Comments
 (0)