Skip to content

Auto schema generation#13

Open
vincerubinetti wants to merge 14 commits into
mainfrom
schema
Open

Auto schema generation#13
vincerubinetti wants to merge 14 commits into
mainfrom
schema

Conversation

@vincerubinetti

Copy link
Copy Markdown
Collaborator

No description provided.

@netlify

netlify Bot commented Apr 27, 2026

Copy link
Copy Markdown

Deploy Preview for m2on failed.

Name Link
🔨 Latest commit fc732f0
🔍 Latest deploy log https://app.netlify.com/projects/m2on/deploys/6a33196de9512500079d429e

@falquaddoomi

falquaddoomi commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Hey @vincerubinetti, sorry for the huge delay. After finally squaring away the search optimizations and other issues, I found that the typing changes needed for this PR are actually pretty modest.

I've pushed a few commits that add the annotations and re-ran the schema generation. It now completes with one warning:

/app/src/api/views.py:530: Warning [CartViewSet]: could not resolve authenticator <class 'api.utils.auth.CsrfExemptSessionAuthentication'>. There was no OpenApiAuthenticationExtension registered for that class. Try creating one by subclassing it. Ignoring for now.

IMO it's fine to ignore that; basically, the cart view is exempt from CSRF verification because it uses an "unsafe" operation (POST) and having to send you a CSRF token to submit with the request is IMHO tedious and unnecessary. The CSRF exemption doesn't actually change the return type, but since it's not annotated OpenAPI doesn't know that and throws a warning.

I've committed the updated data/schema.yaml and will keep it up to date as I make changes to the API.

AFAICT it's working now, so I'd be in favor of merging this. Once it's reconciled with main I'll re-run the schema generation and push it as a hotfix commit.

@falquaddoomi falquaddoomi self-requested a review June 12, 2026 17:37
@vincerubinetti

Copy link
Copy Markdown
Collaborator Author

Ready to merge when you are.

If I understand correctly, this will also resolve the actual runtime differences which are currently causing e.g. the search, sample popup, etc. to error with schema validations?

@falquaddoomi

Copy link
Copy Markdown
Collaborator

Actually, sorry, I missed the reference to target: "../../../data/schema.yaml" in frontend/src/api/orval.config.cjs. At the moment the frontend container doesn't mount data; I'll correct that and see if it works.

If I understand correctly, this will also resolve the actual runtime differences which are currently causing e.g. the search, sample popup, etc. to error with schema validations?

I presume so; I assume Orval will rewrite types.ts with something that matches the OpenAPI schema, so it should resolve the typing mismatches between the backend and frontend. I'll add the schema generation step to the frontend entrypoint command prior to either serving it in dev or building a bundle so that it always gets an up-to-date types.ts file.

FWIW, I just ran the schema generation and it's unhappy about CartViewSet; specifically, I see this in the browser console and the page doesn't render:

Uncaught SyntaxError: The requested module '/src/api/types.ts' does not provide an export named 'cart' (at cart.ts:4:10)

Apparently Spectacular chose not to emit type definitions for CartViewSet at all, I assume due to the warning. It's not super hard to resolve that warning, so I'll go ahead and do that and then retry it.

falquaddoomi and others added 7 commits June 12, 2026 12:35
…for types gen. Updates frontend path to /data/schema.yaml"
…ort container types gen, falling back to the original path for host types gen
…tend types accordingly. Search.tsx now comma-joins the list rather than displaying it verbatim.
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 this pull request may close these issues.

2 participants