types-generator's People
Forkers
manhp-codeleaptypes-generator's Issues
Some required patches don't get applied
I'm using this library against https://api.musement.com/swagger_3.4.0.json
and heavily relying on --patchSource
option to patch the original swagger definition and manually set the required props.
I found out that a few entities don't receive the required attributes specified in the patch file:
Patch file
"CartItemMusementGiftbox": {
"required": ["type", "product"]
},
Output
export type CartItemMusementGiftbox = CartItem & {
type?: "musement-giftbox",
product?: Giftbox
} & {};
It seems to happen with types declared as union of other types.
I noticed that the declaration shows and extra & {}
appended at the and of it. Could it be that the patch gets applied to this empty object type?
Error on enum string contain single quote
eg: if enum contain single quote in it's body => when pass to prettier => it should be error
From openApi:
eg: enum : [
"this is normal",
"but this's why cause error" # => this will cause error on parser
]
Support Swagger's "additionalProperties" keyword for object with dynamic keys
In an OpenAPI document, when an object has some dynamic keys, it's declared like so:
someObject:
type: object
additionalProperties:
type: string
Currently, the additionalProperties keyword is ignored, and the Typescript type is generated in this way:
someObject: {}
If you are using typescript-eslint
> v5.0.0, this will raise an error, because the empty object literal
syntax is banned, as it is considered unsafe. Instead we should use:
someObject: Record<string, string>
In addition to the example shown above, there are other use cases for additionalProperties
:
someObject:
type: object
additionalProperties: true
If the dictionary values can be of any type (aka free-form object) --> Record<string, unknown>
someObject:
type: object
additionalProperties:
$ref: '#/components/schemas/Message'
Instead of using an inline schema, additionalProperties can $ref another schema
someObject:
type: object
properties:
default:
type: string
required:
- default
additionalProperties:
type: string
When a dictionary has some fixed properties, and some dynamic ones.
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.