Comments (3)
It seems like this could be accomplished with a general union type which expresses all the basic types which openAPI supports, and the Exclude
utility type:
type GenericTypes =
| { [key: string]: unknown }
| unknown[]
| string
| number
| boolean;
type nonNumber = Exclude<GenericTypes, number>;
Of course the example in the docs cannot actually be statically narrowed at all, due to Typescript having no integer type 🙂
from openapi-typescript.
I actually haven’t used Exclude<>
much! But it looks promising.
🤔 I think your solution is absolutely perfect for primitives. But my hesitation would be when it comes to advanced types. Like, what would not: { $ref: '…' }
look like?
I haven’t run across not
used in a real-world schema, and I couldn‘t get a good picture from the spec how this is enforced. Should we just put a pin in this until someone has a real-world example how they use it?
from openapi-typescript.
Good point(s). Waiting for a sample usecase sounds like a good plan to me 👍
from openapi-typescript.
Related Issues (20)
- Add an option to generate type aliases for schemas HOT 2
- Exception in catch block: `TypeError: Response.text: Body has already been consumed.` HOT 2
- Request Header 'Content-Type' no longer set for requests with body serialized as FormData HOT 3
- after upgrade from 0.8.2 to 0.9.1, receiving several errors all inside openapi-fetch HOT 5
- transforming enum to delete the pathname at the enum name HOT 4
- Copy the API version to output file HOT 1
- proposal: openapi-fetch new send function HOT 5
- Document Chinese support HOT 8
- Allow providing custom `Request` and `Response` HOT 1
- 7.x nullable enum bug HOT 3
- Circular reference when using inheritance & polymorhism with discriminator HOT 5
- Custom fetch options are stripped from the request. Next.js cache doesn't work properly. HOT 3
- Is there some way to generate responses as non-optional even if not 'required' in the schema? HOT 1
- Discriminator Mapping Support for oneOf HOT 3
- Fetch method type incorrectly blocks `headers` HOT 2
- Replace vitest-fetch-mock with msw in tests
- Lost type-safety while modify response in the middleware HOT 2
- #1580 causes type issue in `MaybeOptionalInit` HOT 1
- Getting 415s on all PUT, POST HOT 1
- Request for Option to Map `OneOf` to union HOT 1
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.