Trying to generate a OpenAPI C client - repeatedly fails to generate "any_type.h"
š
Trying to explore and see if Convex might be a good choice for a simple side project. I'm basically looking to interact with Convex through a Zig application.
That being the case, it seemed like generating a C client is the right call, unfortunately the generator appears to constantly fail to generate the necessary files. When I go to build, the compiler keeps complaining about a missing file called
Not sure whether it's an issue with the spec generator or OpenAPI itself; figured I'd ask here first. If it matters I'm on Windows. For reference, this is pretty much the api I need:
any_type.h
Not sure whether it's an issue with the spec generator or OpenAPI itself; figured I'd ask here first. If it matters I'm on Windows. For reference, this is pretty much the api I need:
import {mutation, query} from "./_generated/server";
import {v} from "convex/values"
export const get = query({
args: {}, handler: async (ctx) => {
return await ctx.db.query("links").collect()
}
})
export const add = mutation({
args: {
label: v.string(),
city: v.string(),
ip: v.string(),
link_id: v.string()
},
handler: async (ctx, args) => {
return await ctx.db.insert("stats", {...args})
}
})
Thank you!š11 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
hi! one wild aside, not to dodge your original question... but we have a high quality (https://crates.io/crates/convex) rust crate that we've been building python, kotlin, and swift bindings with lately. dunno if @dowski (who has been doing this work lately) has any tips on ending up with a nice C API from the rust crate
hi! i can also help with debugging this issue. can you please tell me which OpenAPI generator you are using and the full error message?
Ah... that's a good idea! Can't believe I didn't think of that.
I actually already have some idea of how that might work but open to any concrete instructions you might have dowski
I'm just using whatever the latest one is thats on NPM.
Full error is
fatal error: any_type.h: No such file or directory
ok, I think I have something working in Rust but still need to test. That said it's a bit more verbose than I would have liked.
Still open to any ideas on how to generate via OpenAPI or where to look next.I'm just using whatever the latest one is thats on NPM.I'm guessing you're referring to our spec generator -- Convex -> OpenAPI spec I think Jordan was asking about the generator that goes from the OpenAPI spec to a C project (.c/.h), which one of those you're using
Sorry for not clarifying. OpenAPI does offer the cli via npm
https://openapi-generator.tech/docs/installation#npm
But if one of the other versions is known to be more reliable I'd consider trying that(NPM was the most convenient option)
CLI Installation | OpenAPI Generator
There are a number of ways to use OpenAPI Generator. This page documents how to install the CLI artifact.
hi! for the Kotlin and Swift clients that are built on the Rust lib, we're using https://github.com/mozilla/uniffi-rs which handles the binding generation for those languages
GitHub
GitHub - mozilla/uniffi-rs: a multi-language bindings generator for...
a multi-language bindings generator for rust. Contribute to mozilla/uniffi-rs development by creating an account on GitHub.
it looks like there's 3rd party C++ support for binding generation, although it looks like it doesn't support async functions
the Rust
ConvexClient
exposes async methods, so that probably won't work for your use caseThanks for the link @dowski ! I didn't know this project exists. Bookmarking for later.
I actually managed to cobble something together; after testing my duct-tapped library using your folks' Rust crate it looks like it'll work well enough for my purposes. Not sure how to mark this as "closed" but feel free to close this.
But that said, I think it would still be great to figure out why the openapi cli isn't generating the
any_type.h
header.i can help you further debug the OpenAPI spec generator. .h is a C++ file type, so iām curious if there is something weird going on with the generator.
which version of the generator are you using?
after a quick search, i saw this
it may be worth trying another generator to see if that also runs into the same issue
Apologies! Totally didn't see this till now but I think I'm fine using the Rust library I patched together. The generated C libraries from that seems to work for my purposes.
Appreciate the help!