-
-
Notifications
You must be signed in to change notification settings - Fork 529
Description
What are the steps to reproduce this issue?
- Open codesandbox link here: https://codesandbox.io/p/devbox/slgr4l
- run
pnpm run orvalin terminal or start development from terminal GUI in
I already run that command so you can also look at the generated TS file. I added both "stripped" version of schema yaml and full one. Currently stripped one is used for generation and should be enough but if needed orval.config can be switched to use full version.
Here is a google drive link for schema files: https://drive.google.com/drive/folders/1CtwFX2peUVhFRpPqgDjZMqNY-5FS30b2?usp=sharing
What happens?
Backend is written in Django and Django rest framework so we use drf spectacular for generating open api schema. What happens is, Orval correctly generates all the types but for some reason few enums are used before they are generated. For example on line 1540: export const SubjectRequestIcon = { ...SubjectIconEnum, ...BlankEnum, ...NullEnum } as const; , both BlankEnum and NullEnum are used but they are declared much further in the file (line ~8449 and ~5053). These two are most prevalent since they are used on every model that uses Django's choice filed and can be null in database. There are two more enums that are used before they are declared if it helps: ProductIconEnum and LevelEnum.
What were you expecting to happen?
That enumas that are used to construct other enums are generated before them so we don't get TS errors.
Any logs, error output, etc?
There is no logs, errors or anything in CLI - everything runs fine but the generated file has typescript errors:
Block-scoped variable 'BlankEnum' used before its declaration.ts(2448)Variable 'BlankEnum' is used before being assigned.ts(2454)
Any other comments?
I attached schema.yaml if it helps and here is orval output config:
output: {
target: './src/features/api/orval/',
indexFiles: true,
client: 'fetch',
mode: 'tags-split',
clean: true,
prettier: true,
baseUrl: 'http://0.0.0.0:8081',
urlEncodeParameters: true,
headers: true,
override: {
useNamedParameters: true,
suppressReadonlyModifier: true,
useTypeOverInterfaces: true,
contentType: {
include: [
'application/json',
'text/plain',
'application/x-www-form-urlencoded',
'multipart/form-data',
],
},
},
},
What versions are you using?
Operating System: MacOS
Package Version: 6.31.0
Browser Version: Newest Chrome