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

Registry Types schema endpoint in Bevy Remote Protocol #16745

Closed
Leinnan opened this issue Dec 10, 2024 · 2 comments · Fixed by #16882
Closed

Registry Types schema endpoint in Bevy Remote Protocol #16745

Leinnan opened this issue Dec 10, 2024 · 2 comments · Fixed by #16882
Labels
A-Dev-Tools Tools used to debug Bevy applications. A-Reflection Runtime information about types C-Feature A new feature, making something new possible S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@Leinnan
Copy link
Contributor

Leinnan commented Dec 10, 2024

Basically export_types functionality from blenvy package adapted for Bevy Remote Protocol. Extra points if there would be a in game functionality that would allow to save that export types at runtime.

@Leinnan Leinnan added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Dec 10, 2024
@alice-i-cecile alice-i-cecile added A-Dev-Tools Tools used to debug Bevy applications. A-Reflection Runtime information about types and removed S-Needs-Triage This issue needs to be labelled labels Dec 11, 2024
@alice-i-cecile
Copy link
Member

This looks like the code. This seems like a schema using reflection information to encode the information about all of the registered types; is that correct?

@Leinnan
Copy link
Contributor Author

Leinnan commented Dec 11, 2024

@alice-i-cecile Yep, that is my understanding as well.

@BenjaminBrienen BenjaminBrienen added the S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! label Dec 24, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 26, 2024
# Objective

Resolve #16745

## Solution

Provide a way to map `AppTypeRegistry` types into a JSON Schema that can
be used in other applications. I took code from
https://github.com/kaosat-dev/Blenvy as a starting point, cleaned up and
adapter more for `bevy_remote` needs. Based on feedback and needs it
could be improved, I could add some filtering options, etc.

## Testing

- I was comparing results with the ones from code in `blenvy`
- There is added unit test, could be added more
- I was testing it in my game with this code:
```rust
fn types_to_file(world: &mut World) {
    use bevy_remote::builtin_methods::export_registry_types;
    let Ok(Ok(types_schema)) = world.run_system_cached_with(export_registry_types, None) else {
        return;
    };
    let registry_save_path = std::path::Path::new("assets").join("registry.json");
    let writer =
        std::fs::File::create(registry_save_path).expect("should have created schema file");
    serde_json::to_writer_pretty(writer, &types_schema).expect("Failed to save types to file");
}
```
It can be run by adding it at startup 
```rust
app.add_systems(Startup, types_to_file);
```

---------

Co-authored-by: Gino Valente <[email protected]>
ecoskey pushed a commit to ecoskey/bevy that referenced this issue Jan 6, 2025
# Objective

Resolve bevyengine#16745

## Solution

Provide a way to map `AppTypeRegistry` types into a JSON Schema that can
be used in other applications. I took code from
https://github.com/kaosat-dev/Blenvy as a starting point, cleaned up and
adapter more for `bevy_remote` needs. Based on feedback and needs it
could be improved, I could add some filtering options, etc.

## Testing

- I was comparing results with the ones from code in `blenvy`
- There is added unit test, could be added more
- I was testing it in my game with this code:
```rust
fn types_to_file(world: &mut World) {
    use bevy_remote::builtin_methods::export_registry_types;
    let Ok(Ok(types_schema)) = world.run_system_cached_with(export_registry_types, None) else {
        return;
    };
    let registry_save_path = std::path::Path::new("assets").join("registry.json");
    let writer =
        std::fs::File::create(registry_save_path).expect("should have created schema file");
    serde_json::to_writer_pretty(writer, &types_schema).expect("Failed to save types to file");
}
```
It can be run by adding it at startup 
```rust
app.add_systems(Startup, types_to_file);
```

---------

Co-authored-by: Gino Valente <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dev-Tools Tools used to debug Bevy applications. A-Reflection Runtime information about types C-Feature A new feature, making something new possible S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants