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

Fastify plugin generates module with an invalid path #187

Closed
tajnymag opened this issue Mar 3, 2024 · 3 comments · Fixed by #191
Closed

Fastify plugin generates module with an invalid path #187

tajnymag opened this issue Mar 3, 2024 · 3 comments · Fixed by #191

Comments

@tajnymag
Copy link

tajnymag commented Mar 3, 2024

🐛 Bug Report

The output of the fastify plugin generates without a separator on Windows 11. Probably a mismatched separator.

To reproduce, I've created a test repository and a test workflow. Compared to #186 this issue happens only windows and not linux.

Reproduction

Expected behavior

// File autogenerated with "openapi-ts-json-schema". Do not edit :)

import componentsSchemasHelloWorld from "./componentsschemasHelloWorld";

const componentsSchemasHelloWorldWithId = {
  ...componentsSchemasHelloWorld,
  $id: "/componentsschemasHelloWorld",
} as const;

// Allows json-schema-to-ts to hydrate $refs via the "references" option
export type RefSchemas = [typeof componentsSchemasHelloWorldWithId];

// $ref JSON schemas to be registered with "fastify.addSchema"
export const refSchemas = [componentsSchemasHelloWorldWithId];

// Extra JSON schemas to be registered with "fastify.addSchema"
export const sharedSchemas = [];

Actual behavior

// File autogenerated with "openapi-ts-json-schema". Do not edit :)

import componentsSchemasHelloWorld from "./components/schemas/HelloWorld";

const componentsSchemasHelloWorldWithId = {
  ...componentsSchemasHelloWorld,
  $id: "/componentsschemasHelloWorld",
} as const;

// Allows json-schema-to-ts to hydrate $refs via the "references" option
export type RefSchemas = [typeof componentsSchemasHelloWorldWithId];

// $ref JSON schemas to be registered with "fastify.addSchema"
export const refSchemas = [componentsSchemasHelloWorldWithId];

// Extra JSON schemas to be registered with "fastify.addSchema"
export const sharedSchemas = [];

Run npx envinfo --preset jest

Paste the results here:

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
  Binaries:
    Node: 21.6.2 - ~\scoop\apps\nodejs\current\node.EXE
    Yarn: 1.22.19 - ~\scoop\apps\nodejs\current\yarn.CMD
    npm: 10.2.4 - ~\scoop\apps\nodejs\current\npm.CMD
    pnpm: 8.15.3 - ~\scoop\apps\nodejs\current\pnpm.CMD
@toomuchdesign toomuchdesign linked a pull request Mar 5, 2024 that will close this issue
3 tasks
@toomuchdesign toomuchdesign mentioned this issue Mar 5, 2024
3 tasks
@toomuchdesign
Copy link
Owner

Hey @tajnymag,
this library and its dev environment should be now able to run on Windows. I'm releasing soon.

Thanks again for the issues and relevant repros! Feel free to contribute back or open other issues with any real world feedback ✌️

@tajnymag
Copy link
Author

tajnymag commented Mar 5, 2024

Hey @tajnymag, this library and its dev environment should be now able to run on Windows. I'm releasing soon.

Thanks again for the issues and relevant repros! Feel free to contribute back or open other issues with any real world feedback ✌️

Amazing. Thanks a lot! When I get time, I might have a look at extending the fastify plugin.

@toomuchdesign
Copy link
Owner

Sounds lovely! I intensively use openapi-ts-json-schema on a few real world projects, while the whole plugin part is still a semi-working proof of concept.

The idea behind Fastify plugin was to enable fastify and fastify/swagger to register all the needed schemas one by one and re-expose the OpenApi definition with the registered schemas exposed as components.schemas instead of being inlined as paths definitions.

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

Successfully merging a pull request may close this issue.

2 participants