Best tool to use for Open API Generation of TS library ?!
w
Todays Beliisma Q: What library or tool are you using to generate a TypeScript library there is so many Open API generation tools its a bit overwhelming.
Discovered one from Microsoft, but again soooo many choices out there. How do you know which is a best fit ?!
I have come across the one from Microsoft. But its not happy because of some regex rule, because the stuff coming from Umbraco for the security bits is called 'Umbraco Backoffice' > error: #/components - The key 'Backoffice User' in 'securitySchemes' of components MUST match the regular expression '^[a-zA-Z0-9\.\-_]+$'
Kiota from Microsoft https://github.com/microsoft/kiota https://marketplace.visualstudio.com/items?itemName=ms-graph.kiota So this one is a no for now with the above error/problem. Onto the next codegen tool.....
Looking at the oh wise ones to give some insights or recommendations on CodeGen tools. @Kevin Jump @Niels Lyngsø or @Jacob Overgaard please
Next one I'm gonna try....* (after school run)* https://openapi-ts.pages.dev
j
We use this one and are quite happy with it: https://www.npmjs.com/package/openapi-typescript-codegen
very low key
if you use that one, our configuration fits right in to your custom controllers
k
yes - i have that one in the package.json (lifted from the core)
j
this is what I do in my entryPoint extension to set up authentication:
Copy code
ts
  import { OpenAPI } from "./api";
  import { UMB_AUTH_CONTEXT } from "@umbraco-cms/backoffice/auth";

  ...

  host.consumeContext(UMB_AUTH_CONTEXT, (auth) => {
    const config = auth.getOpenApiConfiguration();
    console.log('Configured auth for OpenAPI:', config.base);
    OpenAPI.BASE = config.base;
    OpenAPI.WITH_CREDENTIALS = config.withCredentials;
    OpenAPI.CREDENTIALS = config.credentials;
    OpenAPI.TOKEN = config.token;
  });
k
runs, generates it all in an api folder, works really nice.
w
Does it need to be v0.25.0 as I see there is v0.27
k
yes, i found 0.27 broke it, there is an issue in their repo
w
Well probably makes sense to align with what core team gang are doing
OK glad I checked with you both.
j
Ohh, I just upgraded the main branch to 0.27 today 😄
what is broken, @Kevin Jump ?
k
I can't quite remember it didn't generate from my swagger, i think it was a folder option...
maybe it was 0.26, but i thought it was 0.27 too.
k
I used the non https end point 🙂
w
ha didnt think to try that 😂
Thanks that worked. Is that what your doing as well Jacob ?!
j
Yes, @Warren Buckley indeed. I think there is a Nodejs environment variable you can set whilst running the command and it should bypass the certificate validation, but it's just easier pointing to the http port.
w
OK sounds like thats the way to go then
10 Views