pagopa / openapi-codegen-ts Goto Github PK
View Code? Open in Web Editor NEWApp IO - Utils
License: European Union Public License 1.2
App IO - Utils
License: European Union Public License 1.2
I am this parameter in a request
{
"name" : "bundleType",
"in" : "query",
"description" : "Boundles's type",
"required" : false,
"style" : "form",
"explode" : true,
"schema" : {
"type" : "string",
"enum" : [ "GLOBAL", "PRIVATE", "PUBLIC" ]
}
}
the generated class is
// Request type definition
export type GetBundlesByPSPT = r.IGetApiRequestType<
{
readonly JWT: string;
readonly limit?: number;
readonly "bundle-type"?: array;
readonly page?: number;
readonly "psp-code": string;
readonly name?: string;
},
"Authorization",
never,
r.IResponseType<200, Bundles, "X-Request-Id">
>;
I have a compile error due to the line readonly "bundle-type"?: array;
readonly "bundle-type"?: Array<string>;
Hi,
I have installed last node packet of italia-utils but when I execute any command I have this result:
gen_api_models_1.generateApi(env, argv["api-spec"], argv["out-dir"], argv["ts-spec-file"], argv.strict
TypeError: Cannot read property 'api-spec' of undefined
Es input:
gen-api-models --help
gen-api-models --api-spec https://raw.githubusercontent.com/teamdigitale/italia-backend/v0.0.27/api_proxy.yaml --out-dir ./definitions/backend
Operations which produce octet/stream
responses will be resolved into generated definitions using Buffer
as defined in #293
This breaks the build of SDK packages as Buffer
is not a native Typescript type
Example
swagger: '2.0'
info:
version: 1.0.0
title: API
host: localhost
basePath: /api/v1
schemes:
- https
paths:
/mypath:
get:
summary: An endpoint
produces:
- application/octet-stream
responses:
'200':
description: Success
schema:
format: binary
type: string
'400':
description: Bad Request
'500':
description: Internal Server Error
requestTypes.ts:2047:8 - error TS4016: Type parameter 'A0' of exported function has or is using private name 'Buffer'.
This repo supports OpenAPI v3
Just supports Swagger v2
This is for Google Summer of Code
to test for response serializers
they are missing
We have examples of specifications using reference not only to a definition but to one specific property. Is it allowed? Reading OpenAPI docs I found neither confirmation nor disprove, and online validators don't complaint.
We should support such case in our generator.
Example
definitions:
Item:
type: object
properties:
status:
type: string
revocation_date:
$ref: '#/definitions/Otp/properties/expires_at'
revocation_reason:
type: string
minLength: 1
Otp:
type: object
properties:
code:
type: string
expires_at:
type: string
format: UTCISODateFromString
description: A date-time field in ISO-8601 format and UTC timezone.
ttl:
type: number
required:
- code
- expires_at
- ttl
The following line should be removed or commented because it's not a valid JS content:
The following error occurs generating types from yaml:
Error: SyntaxError: ';' expected. (4:7)
2 | /* tslint:disable:object-literal-sort-keys */
3 | /* tslint:disable:no-duplicate-string */
> 4 | added this line
| ^
5 | // DO NOT EDIT
Request types for the PATCH
operations are generated.
The generation of request types for PATCH
operations is skipped.
I try to use this tool to generate the client from this swagger
In the swagger we have a custom X-Request-Id
header in request and response and this is a problem for the tool.
I found that the only allowed headers are:
export declare type RequestHeaderKey = "Accept-Encoding" | "Authorization" | "Content-Type" | "Host" | "If-None-Match" | "Ocp-Apim-Subscription-Key" | "X-Functions-Key";
The gen-api-models command generates right code when specs don't specify any type for error responses (!== 200)
The gen-api-models command generats wrong code when specs don't specify any type for error responses and the command uses the default error type as a fallback --default-error-type
Request body is tested.
It's not.
syntax of src/tests/api.yaml to be correct
opening on swagger editor I get the following error:
Structural error at definitions.OneOfTest
should NOT have additional properties
additionalProperty: oneOf
Jump to line 69
This is because gen-api-models supports oneOf
schema feature from OAS3. This ticket
could be closed once OAS3 support will be completed:
If in the openapi v3 there is an optional header for the request the generated client expects it as param (can be undefined
)
Example openapi:
"headers" : {
"X-Request-Id" : {
"description" : "This header identifies the call",
"schema" : {
"type" : "string"
}
}
}
I want to ignore the optional header. Now I'm forced to pass it to the client.
Issue Description
Yaml->Ts Generator miss minLength=0 from Yaml Def and generate wrong types (just string instead of WithinRangeString)
Current Behavior
Yaml Source:
EmptyString:
type: string
minLength: 0
maxLength: 0
LimitedString:
type: string
minLength: 0
maxLength: 4000
Ts Output:
export type EmptyString = t.TypeOf<typeof EmptyString>;
export const EmptyString = t.string;
export type LimitedString= t.TypeOf<typeof LimitedString>;
export const LimitedString= t.string;
Expected/Correct Behavior
Ts Output:
export type EmptyString = t.TypeOf<typeof EmptyString>;
export const EmptyString = WithinRangeString(0, 1);
export type LimitedString= t.TypeOf<typeof LimitedString>;
export const LimitedString= WithinRangeString(0, 4001);
Solution:
Into macros.njk file, change
{% elif definition.minLength and definition.maxLength %}
TO
{% elif definition.minLength!==undefined and definition.maxLength!==undefined %}
In this way, 0
value will be recognized and used
Getting this error on generated code that uses utility functions from italia-ts-commons.
Versions:
io-ts: 2.0.1
italia-utils: 4.1.0
typescript: 3.7.2
Type definitions seem like they should be compatible but getting this error. Any ideas on resolving?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.