oxidecomputer / oxidecomputer/progenitor

Not yet implemented: more media types than expected for pfsense REST API schema

Open
#1,211 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1k
Forks
136
Avg merge
8h 36m
Merged PRs (30d)
14

Description

Here's the schema source: https://pfrest.org/api-docs/openapi.json

Here's the build.rs I'm using to generate the source:

fn main() {
    let src = "schema/pfsense-schema.json";
    println!("cargo:rerun-if-changed={}", src);
    let file = std::fs::File::open(src).unwrap();
    let spec = serde_json::from_reader(file).unwrap();
    let mut binding = progenitor::GenerationSettings::default();
    let settings = binding.with_interface(progenitor::InterfaceStyle::Builder);
    let mut generator = progenitor::Generator::new(&settings);

    let tokens = generator.generate_tokens(&spec).unwrap();
    let ast = syn::parse2(tokens).unwrap();
    let content = prettyplease::unparse(&ast);

    let mut out_file = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
    out_file.push("codegen.rs");

    std::fs::write(out_file, content).unwrap();
}

I'm then just include!ing it inside the lib.rs that I'm going to use

This is the error output I'm getting (with some paths snipped):

failed to run custom build command for `pfsense-api v0.1.0 (/home/doni/<snip>/pfsense-api)`

Caused by:
  process didn't exit successfully: `/home/doni/<snip>/target/debug/build/pfsense-api-9b59366101e86f1d/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=schema/pfsense-schema.json

  --- stderr

  thread 'main' panicked at /home/doni/.cargo/git/checkouts/progenitor-c11fbe48354ec7ff/aa2892e/progenitor-impl/src/method.rs:2048:23:
  not yet implemented: more media types than expected for postAuthJWTEndpoint: 2
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using build.rs and schema/pfsense-schema.json, then inspect progenitor-impl/src/method.rs around the panic for postAuthJWTEndpoint. Compare the operation's two media types in the referenced OpenAPI schema and determine the expected generated output; done means generation completes without the not-yet-implemented panic and the resulting code can be included by lib.rs.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rust
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.