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

Fields missing? #499

Closed
dmgorsky opened this issue Dec 1, 2023 · 6 comments
Closed

Fields missing? #499

dmgorsky opened this issue Dec 1, 2023 · 6 comments

Comments

@dmgorsky
Copy link
Contributor

dmgorsky commented Dec 1, 2023

Inspecting the code, noticed that
pub struct ListCollaboratorsBuilder might lack affiliation, permission
and
pub struct Collaborator might lack role_name
according to
https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators

@shawnyu5
Copy link

I've also noticed with octocrab::models::workflows::Run is missing top level keys, such as run_started_at.

Not sure if this is by design, but it seems the structs defined in Octocrab is not a one-to-one mapping of what the GitHub api returns.

@dmgorsky
Copy link
Contributor Author

I guess I'll review actual schemas some day

@dmgorsky
Copy link
Contributor Author

dmgorsky commented Jan 8, 2024

So I took yaml from here https://github.com/github/rest-api-description/tree/main/descriptions/api.github.com

Extracted URLS with tags

use std::{fs::File,
          io::BufWriter};
use std::io::Write;

use serde_yaml::Value;

fn main() -> std::io::Result<()> {
    fn find_methods(gk: Option<&Value>) -> Option<&Value> {
        let methods: Vec<_> = "get|post|put|patch|delete".split('|').collect();
        for method in methods {
            let try_method = gk.and_then(|gk| gk.get(method));
            if try_method.is_some() { return try_method; }
        }
        None
    }
    //
    
    let delim = '\t';
    let f = File::open("api.github.com.2022-11-28.yaml").unwrap();
    let out_file = File::create("api.github.com.2022-11-28.tsv").unwrap();
    let mut writer = BufWriter::new(out_file);
    
    let data: Value = serde_yaml::from_reader(f).unwrap();
    let q = data.get("paths").unwrap();
    writer.write_all(format!("TAG{delim}URL\n").as_ref())?;
    println!("TAG{delim}URL");
    match q {
        Value::Sequence(sq) => println!("Sequence of {}", sq.len()),
        Value::Mapping(m) => {
            for key in m.keys() {
                let gk = m.get(key);
                let gk = find_methods(gk);
                let gk = gk
                    .and_then(|gk| gk.get("tags"))
                    .and_then(|gs| gs.as_sequence());
                
                if let Some(gk_contents) = gk {
                    if let Some(tag) = gk_contents.first() {
                        print!("{}{delim}", tag.as_str().unwrap());
                        writer.write_all(format!("{}{delim}", tag.as_str().unwrap()).as_ref())?;
                    } else {
                        print!("-{delim}");
                        writer.write_all(b"-{delim}\n")?
                    }
                }
                println!("{}", key.as_str().unwrap());
                writer.write_all(format!("{}\n", key.as_str().unwrap()).as_ref())?
            }
        }
        Value::String(st) => println!("String {}", st),
        _ => println!("---")
    }
    let _ = writer.flush();
    
    Ok(())
}

and here is the result.
api.github.com.2022-11-28.tsv.zip
Now going to sort it and roughly compare with the crate.

@XAMPPRocky
Copy link
Owner

Thank you for your issue! PRs adding missing fields are welcome and encouraged 🙂

@dmgorsky
Copy link
Contributor Author

dmgorsky commented Jan 17, 2024

Thank you for your issue! PRs adding missing fields are welcome and encouraged 🙂

we might use https://github.com/dmgorsky/github_api_check_for_octocrab for that

@dmgorsky dmgorsky closed this as completed Mar 7, 2024
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