Comments (4)
At this time renaming isn’t supported in TypeScript because it could deviate from your schema; if two objects contained .gender
how would the collision be fixed? Would you have Gender
and Gender2
? And more importantly, would it be clear when importing the type you were importing the correct one?
I’d recommend if you want to refer to an enum often, then move it to be its own top-level schema object in your OpenAPI spec itself. That way your generated types always match 1:1 to your schema, and you’ll never accidentally refer to one type thinking it’s another.
from openapi-typescript.
Every Enum that we defined has unique name. there are no way to create several kinds of enum called duplicated name.
is you mean that change the directory of the file that the enum defined to the top ?
from openapi-typescript.
Oh I had assumed that when you referenced #/components/schemas/com.aaaa.server.core.common.Gender
, you were referencing multiple nested schema objects com
→ aaa
→ server
→ core
→ common
→ Gender
, where each level was a property. In which case my suggestion would be to move it to #/components/schemas/Gender
, and simply use $ref
wherever it’s needed.
But if you are saying that is just a single schema object with periods in the title, then I think that’s the correct name? We want to match your schema 1:1 perfectly, without renames; but as those contain invalid characters we just do our best translating it into a valid JS identifier. But try and preserve the name as-authored so it’s easy-to-find and there’s no confusion.
from openapi-typescript.
Willing to look into it further if you can provide:
- An example OpenAPI schema that generates an enum
- What you expected it to generate
from openapi-typescript.
Related Issues (20)
- Metadata generation
- Allow client option for custom dispatcher into fetch requests (e.g. to disable certificate validation) HOT 6
- advice on how to connect a frontend (swagger?) while using this lib
- Set baseUrl per request
- 0.9.4 breaks some Typescript configurations HOT 3
- Response types from openapi-fetch ignore null values
- Multiple security schemes not supported
- With React Query: Invariant: headers() expects to have requestAsyncStorage, none available. HOT 3
- `--properties-required-by-default` and `--default-non-nullable` flags do not work HOT 1
- Nested object's properties are mapped to unknown, but in OpenAPI they are typed correctly HOT 3
- "AdditionalProperties" reflects onto existing properties and causes TypeScript compile errors HOT 1
- Issues with references (`$ref`) resolution HOT 2
- Error with negative numbers in enums HOT 2
- Allow for custom types in path params serialization (and maybe other places serialization too)
- Types derived for oneOf construct result in TS2502 error HOT 7
- Uncaught error when body is `undefined` in request init HOT 6
- 'path' does not exist in type '{ query?: Record<string, unknown> | undefined; }' HOT 4
- issue on - generate client when yaml has mutiple same external ref
- Generate subset of schema
- Deduplicate enums
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-typescript.