Skip to content

Commit

Permalink
Merge pull request #187 from LumaKernel/main
Browse files Browse the repository at this point in the history
feat: add "or undefined" explicitly to support exactOptionalPropertyTypes
  • Loading branch information
LumaKernel authored Mar 11, 2022
2 parents a07a00f + bcb9830 commit 0f8c519
Show file tree
Hide file tree
Showing 230 changed files with 4,543 additions and 4,529 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.19.0](https://github.com/aspida/openapi2aspida/compare/v0.18.0...v0.19.0) (2022-03-11)

### Features

- add "or undefined" explicitly to support exactOptionalPropertyTypes (https://github.com/aspida/openapi2aspida/pull/187)


## [0.18.0](https://github.com/aspida/openapi2aspida/compare/v0.17.0...v0.18.0) (2022-03-07)


Expand Down
5 changes: 5 additions & 0 deletions aspida.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ module.exports = [
outputEachDir: true,
openapi: { inputFile: 'samples/array-one-of.yml' }
}
// {
// input: 'samples/path-at-mark',
// outputEachDir: true,
// openapi: { inputFile: 'samples/path-at-mark.yml' }
// }
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
]
},
"dependencies": {
"aspida": "^1.7.1",
"aspida": "^1.9.0",
"fs-extra": "^10.0.0",
"js-yaml": "^4.1.0",
"openapi-types": "^9.1.0",
Expand Down
8 changes: 4 additions & 4 deletions samples/array-one-of/$api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable */
// prettier-ignore
import { AspidaClient, BasicHeaders } from 'aspida'
import type { AspidaClient, BasicHeaders } from 'aspida'
// prettier-ignore
import { Methods as Methods0 } from './user'
import type { Methods as Methods0 } from './user'

// prettier-ignore
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
Expand All @@ -15,12 +15,12 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
/**
* @returns sample
*/
get: (option?: { config?: T }) =>
get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json(),
/**
* @returns sample
*/
$get: (option?: { config?: T }) =>
$get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH0}`
}
Expand Down
10 changes: 5 additions & 5 deletions samples/array-one-of/@types/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable */
export type User = {
id?: string
roles?: (RoleA | RoleB)[]
id?: string | undefined
roles?: (RoleA | RoleB)[] | undefined
}

export type RoleA = {
name?: string
name?: string | undefined
}

export type RoleB = {
name?: string
authority?: string
name?: string | undefined
authority?: string | undefined
}
8 changes: 4 additions & 4 deletions samples/array-one-of/user/$api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable */
// prettier-ignore
import { AspidaClient, BasicHeaders } from 'aspida'
import type { AspidaClient, BasicHeaders } from 'aspida'
// prettier-ignore
import { Methods as Methods0 } from '.'
import type { Methods as Methods0 } from '.'

// prettier-ignore
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
Expand All @@ -14,12 +14,12 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
/**
* @returns sample
*/
get: (option?: { config?: T }) =>
get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json(),
/**
* @returns sample
*/
$get: (option?: { config?: T }) =>
$get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH0}`
}
Expand Down
60 changes: 31 additions & 29 deletions samples/externals/$api.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
/* eslint-disable */
// prettier-ignore
import { AspidaClient, dataToURLString } from 'aspida'
import type { AspidaClient } from 'aspida'
// prettier-ignore
import { Methods as Methods0 } from './users/_user_id@string/orders'
import { dataToURLString } from 'aspida'
// prettier-ignore
import { Methods as Methods1 } from './users/_user_id@string/orders/_order_id@string'
import type { Methods as Methods0 } from './users/_user_id@string/orders'
// prettier-ignore
import { Methods as Methods2 } from './users/_user_id@string/orders/purchase/invoice'
import type { Methods as Methods1 } from './users/_user_id@string/orders/_order_id@string'
// prettier-ignore
import { Methods as Methods3 } from './users/_user_id@string/orders/purchase/wallet'
import type { Methods as Methods2 } from './users/_user_id@string/orders/purchase/invoice'
// prettier-ignore
import { Methods as Methods4 } from './users/_user_id@string/orders/unsubscribe'
import type { Methods as Methods3 } from './users/_user_id@string/orders/purchase/wallet'
// prettier-ignore
import { Methods as Methods5 } from './users/_user_id@string/orders/update/renew'
import type { Methods as Methods4 } from './users/_user_id@string/orders/unsubscribe'
// prettier-ignore
import { Methods as Methods6 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders'
import type { Methods as Methods5 } from './users/_user_id@string/orders/update/renew'
// prettier-ignore
import { Methods as Methods7 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/invoice'
import type { Methods as Methods6 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders'
// prettier-ignore
import { Methods as Methods8 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/wallet'
import type { Methods as Methods7 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/invoice'
// prettier-ignore
import type { Methods as Methods8 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/wallet'

// prettier-ignore
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
Expand Down Expand Up @@ -48,13 +50,13 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* Get info of an order by order_id
* @returns Ok
*/
get: (option?: { config?: T }) =>
get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods1['get']['resBody'], Methods1['get']['resHeaders'], Methods1['get']['status']>(prefix, prefix3, GET, option).json(),
/**
* Get info of an order by order_id
* @returns Ok
*/
$get: (option?: { config?: T }) =>
$get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods1['get']['resBody'], Methods1['get']['resHeaders'], Methods1['get']['status']>(prefix, prefix3, GET, option).json().then(r => r.body),
$path: () => `${prefix}${prefix3}`
}
Expand All @@ -66,14 +68,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @param option.body - Body to create a purchase order
* @returns Created
*/
post: (option: { body: Methods2['post']['reqBody'], config?: T }) =>
post: (option: { body: Methods2['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods2['post']['resBody'], Methods2['post']['resHeaders'], Methods2['post']['status']>(prefix, `${prefix1}${PATH2}`, POST, option).json(),
/**
* Creates an purchase order for an offer by its offer_id and using invoice as payment method
* @param option.body - Body to create a purchase order
* @returns Created
*/
$post: (option: { body: Methods2['post']['reqBody'], config?: T }) =>
$post: (option: { body: Methods2['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods2['post']['resBody'], Methods2['post']['resHeaders'], Methods2['post']['status']>(prefix, `${prefix1}${PATH2}`, POST, option).json().then(r => r.body),
$path: () => `${prefix}${prefix1}${PATH2}`
},
Expand All @@ -83,14 +85,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @param option.body - Body to create a purchase order
* @returns Created
*/
post: (option: { body: Methods3['post']['reqBody'], config?: T }) =>
post: (option: { body: Methods3['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods3['post']['resBody'], Methods3['post']['resHeaders'], Methods3['post']['status']>(prefix, `${prefix1}${PATH3}`, POST, option).json(),
/**
* Creates an purchase order for an offer by its offer_id using wallet as payment method
* @param option.body - Body to create a purchase order
* @returns Created
*/
$post: (option: { body: Methods3['post']['reqBody'], config?: T }) =>
$post: (option: { body: Methods3['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods3['post']['resBody'], Methods3['post']['resHeaders'], Methods3['post']['status']>(prefix, `${prefix1}${PATH3}`, POST, option).json().then(r => r.body),
$path: () => `${prefix}${prefix1}${PATH3}`
}
Expand All @@ -101,14 +103,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @param option.body - Body to create a purchase order
* @returns Created
*/
post: (option: { body: Methods4['post']['reqBody'], config?: T }) =>
post: (option: { body: Methods4['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods4['post']['resBody'], Methods4['post']['resHeaders'], Methods4['post']['status']>(prefix, `${prefix1}${PATH4}`, POST, option).json(),
/**
* Creates an unsubscribe order for a product_id
* @param option.body - Body to create a purchase order
* @returns Created
*/
$post: (option: { body: Methods4['post']['reqBody'], config?: T }) =>
$post: (option: { body: Methods4['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods4['post']['resBody'], Methods4['post']['resHeaders'], Methods4['post']['status']>(prefix, `${prefix1}${PATH4}`, POST, option).json().then(r => r.body),
$path: () => `${prefix}${prefix1}${PATH4}`
},
Expand All @@ -119,14 +121,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @param option.body - Body to create a update order
* @returns Created
*/
post: (option: { body: Methods5['post']['reqBody'], config?: T }) =>
post: (option: { body: Methods5['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods5['post']['resBody'], Methods5['post']['resHeaders'], Methods5['post']['status']>(prefix, `${prefix1}${PATH5}`, POST, option).json(),
/**
* Creates an update order for a product_id
* @param option.body - Body to create a update order
* @returns Created
*/
$post: (option: { body: Methods5['post']['reqBody'], config?: T }) =>
$post: (option: { body: Methods5['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods5['post']['resBody'], Methods5['post']['resHeaders'], Methods5['post']['status']>(prefix, `${prefix1}${PATH5}`, POST, option).json().then(r => r.body),
$path: () => `${prefix}${prefix1}${PATH5}`
}
Expand All @@ -135,15 +137,15 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* List orders for a user
* @returns Ok
*/
get: (option?: { query?: Methods0['get']['query'], config?: T }) =>
get: (option?: { query?: Methods0['get']['query'] | undefined, config?: T | undefined } | undefined) =>
fetch<Methods0['get']['resBody'], Methods0['get']['resHeaders'], Methods0['get']['status']>(prefix, `${prefix1}${PATH1}`, GET, option).json(),
/**
* List orders for a user
* @returns Ok
*/
$get: (option?: { query?: Methods0['get']['query'], config?: T }) =>
$get: (option?: { query?: Methods0['get']['query'] | undefined, config?: T | undefined } | undefined) =>
fetch<Methods0['get']['resBody'], Methods0['get']['resHeaders'], Methods0['get']['status']>(prefix, `${prefix1}${PATH1}`, GET, option).json().then(r => r.body),
$path: (option?: { method?: 'get'; query: Methods0['get']['query'] }) =>
$path: (option?: { method?: 'get' | undefined; query: Methods0['get']['query'] } | undefined) =>
`${prefix}${prefix1}${PATH1}${option && option.query ? `?${dataToURLString(option.query)}` : ''}`
},
phone_numbers: {
Expand All @@ -159,14 +161,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @param option.body - Body to create a purchase order
* @returns Created
*/
post: (option: { body: Methods7['post']['reqBody'], config?: T }) =>
post: (option: { body: Methods7['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods7['post']['resBody'], Methods7['post']['resHeaders'], Methods7['post']['status']>(prefix, `${prefix3}${PATH2}`, POST, option).json(),
/**
* Creates an purchase order for an offer by its offer_id using invoice has payment method
* @param option.body - Body to create a purchase order
* @returns Created
*/
$post: (option: { body: Methods7['post']['reqBody'], config?: T }) =>
$post: (option: { body: Methods7['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods7['post']['resBody'], Methods7['post']['resHeaders'], Methods7['post']['status']>(prefix, `${prefix3}${PATH2}`, POST, option).json().then(r => r.body),
$path: () => `${prefix}${prefix3}${PATH2}`
},
Expand All @@ -176,14 +178,14 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* @param option.body - Body to create a purchase order
* @returns Created
*/
post: (option: { body: Methods8['post']['reqBody'], config?: T }) =>
post: (option: { body: Methods8['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods8['post']['resBody'], Methods8['post']['resHeaders'], Methods8['post']['status']>(prefix, `${prefix3}${PATH3}`, POST, option).json(),
/**
* Creates an purchase order for an offer by its offer_id using a wallet has payment method
* @param option.body - Body to create a purchase order
* @returns Created
*/
$post: (option: { body: Methods8['post']['reqBody'], config?: T }) =>
$post: (option: { body: Methods8['post']['reqBody'], config?: T | undefined }) =>
fetch<Methods8['post']['resBody'], Methods8['post']['resHeaders'], Methods8['post']['status']>(prefix, `${prefix3}${PATH3}`, POST, option).json().then(r => r.body),
$path: () => `${prefix}${prefix3}${PATH3}`
}
Expand All @@ -192,13 +194,13 @@ const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
* List orders for a phone number
* @returns Ok
*/
get: (option?: { config?: T }) =>
get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods6['get']['resBody'], Methods6['get']['resHeaders'], Methods6['get']['status']>(prefix, `${prefix3}${PATH1}`, GET, option).json(),
/**
* List orders for a phone number
* @returns Ok
*/
$get: (option?: { config?: T }) =>
$get: (option?: { config?: T | undefined } | undefined) =>
fetch<Methods6['get']['resBody'], Methods6['get']['resHeaders'], Methods6['get']['status']>(prefix, `${prefix3}${PATH1}`, GET, option).json().then(r => r.body),
$path: () => `${prefix}${prefix3}${PATH1}`
}
Expand Down
Loading

0 comments on commit 0f8c519

Please sign in to comment.