Comments (7)
duplicate for #510
from dtsgenerator.
Some debug information so far:
ln#1053 on simple_schema_test the iteration "support components property in OpenAPI v3" gives me the following feedback.
The function addParameterSchema
I do see for Parameters the correct output
for Components.Parameters.PathParameters, namely:
{ GeographyId: { '$ref': '#/components/parameters/GeographyId' } }
since its input is
:
[ [ 'GeographyId', { name: 'geographyId', in: 'path', description: 'unique id of geography', required: true, schema: [Object] } ] ]
But after that for Paths.GetGeography.Parameters i do see "incorrect" output (index number instead of name):
[ [ '0', { '$ref': '#/components/parameters/GeographyId' } ] ]
So the addParameterSchema is not called with an item name and so follows the index number.
from dtsgenerator.
@maapteh Thank you for your bug report 👍
This seems to be the same problem as #510.
The reason for the $0
is that when parsing parameters
, the following code references name
and uses it as the type name. But when using $ref
, this code moves before expanding the reference, so name
is not found and the type name is not taken.
https://github.com/horiuchi/dtsgenerator/blob/master/src/core/jsonSchema.ts#L242
This problem is due to the fact that OpenAPI support was added later, resulting in an unreasonable implementation.
In the future, we plan to make it possible to replace the type generator with different implementations for each version of JSON Schema and each version of OpenAPI, but we have been very busy and have not been able to make progress on this.
At this time, I think it would work better if you use $ref at schema
instead of using $ref
immediately below parameters
.
from dtsgenerator.
With common parameters setup i do not have the queryParams anymore per endpoint.
export namespace FindProductsByCategory {
export namespace Parameters {
...snip...
}
export interface QueryParameters {
minPrice?: Parameters.MinPrice;
maxPrice?: Parameters.MaxPrice;
orderBy?: Parameters.OrderBy;
}
So queryParameters are gone in total. I have not an option anymore. Will look further in what to do, what you advised me to do but i guess the retrieval of endpoints can not be done anymore since api's decided to have common parameters :)
Btw still a great library, lots of people learned about your generator when i got some feedback on my article about it!
from dtsgenerator.
Thanks for using dtsgenerator.
I hadn't done much hand-writing of OpenAPI definitions myself, so thanks to you I now know that this issue is quite important.
For this new comment, I would appreciate a detailed investigation if you would write down the actual input, the actual result, and the expected result.
However, it is probably the same cause of the problem I commented on last one.
from dtsgenerator.
Just wanted to let know that this issue is still relevant, and the fix would save the day for way more than one project.
from dtsgenerator.
We moved to https://orval.dev/overview which besides creating all types (following api spec) also creates the complete hooks for integration for the frontend. Maybe you can have a look as well @kostia1st
from dtsgenerator.
Related Issues (20)
- Support OpenAPI 3.1
- Support `JSON Schema 2020-12` HOT 1
- Use of "oneOf" is not working properly HOT 2
- null choices in nullable enums is cast in string HOT 2
- When definitions are not defined, we hope to be compatible without affecting the export of d.ts file HOT 1
- --useUnionTypes doesn't work on $ref
- Type generation malforming objects with number-like keys HOT 5
- AdditionalProperties in swagger definition creates broken TS interface HOT 9
- Move this project and generate result to ESM HOT 2
- complex nullable type, change in behavior HOT 4
- [Question] Is it possible to export the namespace? HOT 1
- If there are 8s and 9s, they will be zero-suppressed. HOT 3
- Nesting multiple, separate objects defined with oneOf in allOf does not work as expected HOT 2
- jsdoc comments are placed after property name
- How do I suppress long prefices? HOT 1
- Does dtsgenerator support multiple content for requestBody? HOT 2
- All interface properties made optional HOT 2
- nested interfaces? HOT 3
- importing the lib? 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 dtsgenerator.