Skip to content

Commit

Permalink
feat: update [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jun 25, 2020
1 parent 0cd3fec commit 817d128
Show file tree
Hide file tree
Showing 117 changed files with 7,836 additions and 1,223 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 m-mitsuhide <m.mitsuhide@amatelus.com>
Copyright (c) 2020 Solufa <solufa2020@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Create config file in project root
```js
module.exports = {
input: "apis", // "input" of aspida is "output" for openapi2aspida
outputEachDir: true, // Generate $api.ts in each endpoint directory
openapi: { inputFile: "https://petstore.swagger.io/v2/swagger.json" } // Compatible with yaml/json of OpenAPI3.0/Swagger2.0
}
```
Expand Down
6 changes: 6 additions & 0 deletions aspida.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
module.exports = [
{
input: 'samples/swagger',
outputEachDir: true,
openapi: { inputFile: 'samples/swagger.yaml', mock: true }
},
{
input: 'samples/simple',
outputEachDir: true,
openapi: { inputFile: 'samples/simple.yaml', mock: true, noMockType: true }
},
{
input: 'samples/strapi',
outputEachDir: true,
openapi: { inputFile: 'samples/strapi.json' }
},
{
input: 'samples/freee',
outputEachDir: true,
openapi: { inputFile: 'samples/freee.json', mock: true }
},
{
input: 'samples/openapi',
outputEachDir: true,
openapi: { inputFile: 'samples/openapi.json', mock: true, yaml: false }
},
{
input: 'samples/externals',
outputEachDir: true,
openapi: { inputFile: 'samples/externals.json', yaml: false }
}
]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "openapi2aspida",
"version": "0.8.0",
"description": "Convert OpenAPI 3.0 or Swagger 2.0 definitions into aspida",
"author": "m-mitsuhide <m.mitsuhide@amatelus.com>",
"author": "Solufa <solufa2020@gmail.com>",
"license": "MIT",
"main": "dist/index.js",
"bin": "bin/index.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
"swagger"
],
"dependencies": {
"aspida": "^0.18.0",
"aspida": "^0.19.2",
"swagger-parser": "^9.0.1",
"swagger2openapi": "^6.0.3"
},
Expand Down
165 changes: 93 additions & 72 deletions samples/externals/$api.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,107 @@
/* eslint-disable */
import { AspidaClient } from 'aspida'
import { Methods as Methods0 } from './users/_user_id@string/orders/index'
import { Methods as Methods1 } from './users/_user_id@string/orders/_order_id@string/index'
import { Methods as Methods2 } from './users/_user_id@string/orders/purchase/invoice/index'
import { Methods as Methods3 } from './users/_user_id@string/orders/purchase/wallet/index'
import { Methods as Methods4 } from './users/_user_id@string/orders/unsubscribe/index'
import { Methods as Methods5 } from './users/_user_id@string/orders/update/renew/index'
import { Methods as Methods6 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/index'
import { Methods as Methods7 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/invoice/index'
import { Methods as Methods8 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/wallet/index'
import { Methods as Methods0 } from './users/_user_id@string/orders'
import { Methods as Methods1 } from './users/_user_id@string/orders/_order_id@string'
import { Methods as Methods2 } from './users/_user_id@string/orders/purchase/invoice'
import { Methods as Methods3 } from './users/_user_id@string/orders/purchase/wallet'
import { Methods as Methods4 } from './users/_user_id@string/orders/unsubscribe'
import { Methods as Methods5 } from './users/_user_id@string/orders/update/renew'
import { Methods as Methods6 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders'
import { Methods as Methods7 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/invoice'
import { Methods as Methods8 } from './users/_user_id@string/phone-numbers/_phone_number@string/orders/purchase/wallet'

const api = <T>(client: AspidaClient<T>) => {
const prefix = (client.baseURL === undefined ? 'https://api.baikalplatform.com/product-management/v1' : client.baseURL).replace(/\/$/, '')
const GET = 'GET'
const POST = 'POST'
const PATH0 = '/users'
const PATH1 = '/orders'
const PATH2 = '/orders/purchase/invoice'
const PATH3 = '/orders/purchase/wallet'
const PATH4 = '/orders/unsubscribe'
const PATH5 = '/orders/update/renew'
const PATH6 = '/phone-numbers'
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
const prefix = (baseURL === undefined ? 'https://api.baikalplatform.com/product-management/v1' : baseURL).replace(/\/$/, '')

return {
users: {
_user_id: (val0: string) => ({
orders: {
_order_id: (val1: string) => ({
get: (option?: { config?: T }) =>
client.fetch<Methods1['get']['resBody'], Methods1['get']['resHeaders'], Methods1['get']['status']>(prefix, `/users/${val0}/orders/${val1}`, 'GET', option).json(),
$get: async (option?: { config?: T }) =>
(await client.fetch<Methods1['get']['resBody'], Methods1['get']['resHeaders'], Methods1['get']['status']>(prefix, `/users/${val0}/orders/${val1}`, 'GET', option).json()).body
}),
purchase: {
invoice: {
post: (option: { body: Methods2['post']['reqBody'], config?: T }) =>
client.fetch<Methods2['post']['resBody'], Methods2['post']['resHeaders'], Methods2['post']['status']>(prefix, `/users/${val0}/orders/purchase/invoice`, 'POST', option).json(),
$post: async (option: { body: Methods2['post']['reqBody'], config?: T }) =>
(await client.fetch<Methods2['post']['resBody'], Methods2['post']['resHeaders'], Methods2['post']['status']>(prefix, `/users/${val0}/orders/purchase/invoice`, 'POST', option).json()).body
_user_id: (val0: string) => {
const prefix0 = `${PATH0}/${val0}`

return {
orders: {
_order_id: (val1: string) => {
const prefix1 = `${prefix0}${PATH1}/${val1}`

return {
get: (option?: { config?: T }) =>
fetch<Methods1['get']['resBody'], Methods1['get']['resHeaders'], Methods1['get']['status']>(prefix, prefix1, GET, option).json(),
$get: (option?: { config?: T }) =>
fetch<Methods1['get']['resBody'], Methods1['get']['resHeaders'], Methods1['get']['status']>(prefix, prefix1, GET, option).json().then(r => r.body)
}
},
wallet: {
post: (option: { body: Methods3['post']['reqBody'], config?: T }) =>
client.fetch<Methods3['post']['resBody'], Methods3['post']['resHeaders'], Methods3['post']['status']>(prefix, `/users/${val0}/orders/purchase/wallet`, 'POST', option).json(),
$post: async (option: { body: Methods3['post']['reqBody'], config?: T }) =>
(await client.fetch<Methods3['post']['resBody'], Methods3['post']['resHeaders'], Methods3['post']['status']>(prefix, `/users/${val0}/orders/purchase/wallet`, 'POST', option).json()).body
}
},
unsubscribe: {
post: (option: { body: Methods4['post']['reqBody'], config?: T }) =>
client.fetch<Methods4['post']['resBody'], Methods4['post']['resHeaders'], Methods4['post']['status']>(prefix, `/users/${val0}/orders/unsubscribe`, 'POST', option).json(),
$post: async (option: { body: Methods4['post']['reqBody'], config?: T }) =>
(await client.fetch<Methods4['post']['resBody'], Methods4['post']['resHeaders'], Methods4['post']['status']>(prefix, `/users/${val0}/orders/unsubscribe`, 'POST', option).json()).body
},
update: {
renew: {
post: (option: { body: Methods5['post']['reqBody'], config?: T }) =>
client.fetch<Methods5['post']['resBody'], Methods5['post']['resHeaders'], Methods5['post']['status']>(prefix, `/users/${val0}/orders/update/renew`, 'POST', option).json(),
$post: async (option: { body: Methods5['post']['reqBody'], config?: T }) =>
(await client.fetch<Methods5['post']['resBody'], Methods5['post']['resHeaders'], Methods5['post']['status']>(prefix, `/users/${val0}/orders/update/renew`, 'POST', option).json()).body
}
purchase: {
invoice: {
post: (option: { body: Methods2['post']['reqBody'], config?: T }) =>
fetch<Methods2['post']['resBody'], Methods2['post']['resHeaders'], Methods2['post']['status']>(prefix, `${prefix0}${PATH2}`, POST, option).json(),
$post: (option: { body: Methods2['post']['reqBody'], config?: T }) =>
fetch<Methods2['post']['resBody'], Methods2['post']['resHeaders'], Methods2['post']['status']>(prefix, `${prefix0}${PATH2}`, POST, option).json().then(r => r.body)
},
wallet: {
post: (option: { body: Methods3['post']['reqBody'], config?: T }) =>
fetch<Methods3['post']['resBody'], Methods3['post']['resHeaders'], Methods3['post']['status']>(prefix, `${prefix0}${PATH3}`, POST, option).json(),
$post: (option: { body: Methods3['post']['reqBody'], config?: T }) =>
fetch<Methods3['post']['resBody'], Methods3['post']['resHeaders'], Methods3['post']['status']>(prefix, `${prefix0}${PATH3}`, POST, option).json().then(r => r.body)
}
},
unsubscribe: {
post: (option: { body: Methods4['post']['reqBody'], config?: T }) =>
fetch<Methods4['post']['resBody'], Methods4['post']['resHeaders'], Methods4['post']['status']>(prefix, `${prefix0}${PATH4}`, POST, option).json(),
$post: (option: { body: Methods4['post']['reqBody'], config?: T }) =>
fetch<Methods4['post']['resBody'], Methods4['post']['resHeaders'], Methods4['post']['status']>(prefix, `${prefix0}${PATH4}`, POST, option).json().then(r => r.body)
},
update: {
renew: {
post: (option: { body: Methods5['post']['reqBody'], config?: T }) =>
fetch<Methods5['post']['resBody'], Methods5['post']['resHeaders'], Methods5['post']['status']>(prefix, `${prefix0}${PATH5}`, POST, option).json(),
$post: (option: { body: Methods5['post']['reqBody'], config?: T }) =>
fetch<Methods5['post']['resBody'], Methods5['post']['resHeaders'], Methods5['post']['status']>(prefix, `${prefix0}${PATH5}`, POST, option).json().then(r => r.body)
}
},
get: (option?: { query?: Methods0['get']['query'], config?: T }) =>
fetch<Methods0['get']['resBody'], Methods0['get']['resHeaders'], Methods0['get']['status']>(prefix, `${prefix0}${PATH1}`, GET, option).json(),
$get: (option?: { query?: Methods0['get']['query'], config?: T }) =>
fetch<Methods0['get']['resBody'], Methods0['get']['resHeaders'], Methods0['get']['status']>(prefix, `${prefix0}${PATH1}`, GET, option).json().then(r => r.body)
},
get: (option?: { query?: Methods0['get']['query'], config?: T }) =>
client.fetch<Methods0['get']['resBody'], Methods0['get']['resHeaders'], Methods0['get']['status']>(prefix, `/users/${val0}/orders`, 'GET', option).json(),
$get: async (option?: { query?: Methods0['get']['query'], config?: T }) =>
(await client.fetch<Methods0['get']['resBody'], Methods0['get']['resHeaders'], Methods0['get']['status']>(prefix, `/users/${val0}/orders`, 'GET', option).json()).body
},
phone_numbers: {
_phone_number: (val2: string) => ({
orders: {
purchase: {
invoice: {
post: (option: { body: Methods7['post']['reqBody'], config?: T }) =>
client.fetch<Methods7['post']['resBody'], Methods7['post']['resHeaders'], Methods7['post']['status']>(prefix, `/users/${val0}/phone-numbers/${val2}/orders/purchase/invoice`, 'POST', option).json(),
$post: async (option: { body: Methods7['post']['reqBody'], config?: T }) =>
(await client.fetch<Methods7['post']['resBody'], Methods7['post']['resHeaders'], Methods7['post']['status']>(prefix, `/users/${val0}/phone-numbers/${val2}/orders/purchase/invoice`, 'POST', option).json()).body
},
wallet: {
post: (option: { body: Methods8['post']['reqBody'], config?: T }) =>
client.fetch<Methods8['post']['resBody'], Methods8['post']['resHeaders'], Methods8['post']['status']>(prefix, `/users/${val0}/phone-numbers/${val2}/orders/purchase/wallet`, 'POST', option).json(),
$post: async (option: { body: Methods8['post']['reqBody'], config?: T }) =>
(await client.fetch<Methods8['post']['resBody'], Methods8['post']['resHeaders'], Methods8['post']['status']>(prefix, `/users/${val0}/phone-numbers/${val2}/orders/purchase/wallet`, 'POST', option).json()).body
phone_numbers: {
_phone_number: (val2: string) => {
const prefix2 = `${prefix0}${PATH6}/${val2}`

return {
orders: {
purchase: {
invoice: {
post: (option: { body: Methods7['post']['reqBody'], config?: T }) =>
fetch<Methods7['post']['resBody'], Methods7['post']['resHeaders'], Methods7['post']['status']>(prefix, `${prefix2}${PATH2}`, POST, option).json(),
$post: (option: { body: Methods7['post']['reqBody'], config?: T }) =>
fetch<Methods7['post']['resBody'], Methods7['post']['resHeaders'], Methods7['post']['status']>(prefix, `${prefix2}${PATH2}`, POST, option).json().then(r => r.body)
},
wallet: {
post: (option: { body: Methods8['post']['reqBody'], config?: T }) =>
fetch<Methods8['post']['resBody'], Methods8['post']['resHeaders'], Methods8['post']['status']>(prefix, `${prefix2}${PATH3}`, POST, option).json(),
$post: (option: { body: Methods8['post']['reqBody'], config?: T }) =>
fetch<Methods8['post']['resBody'], Methods8['post']['resHeaders'], Methods8['post']['status']>(prefix, `${prefix2}${PATH3}`, POST, option).json().then(r => r.body)
}
},
get: (option?: { config?: T }) =>
fetch<Methods6['get']['resBody'], Methods6['get']['resHeaders'], Methods6['get']['status']>(prefix, `${prefix2}${PATH1}`, GET, option).json(),
$get: (option?: { config?: T }) =>
fetch<Methods6['get']['resBody'], Methods6['get']['resHeaders'], Methods6['get']['status']>(prefix, `${prefix2}${PATH1}`, GET, option).json().then(r => r.body)
}
},
get: (option?: { config?: T }) =>
client.fetch<Methods6['get']['resBody'], Methods6['get']['resHeaders'], Methods6['get']['status']>(prefix, `/users/${val0}/phone-numbers/${val2}/orders`, 'GET', option).json(),
$get: async (option?: { config?: T }) =>
(await client.fetch<Methods6['get']['resBody'], Methods6['get']['resHeaders'], Methods6['get']['status']>(prefix, `/users/${val0}/phone-numbers/${val2}/orders`, 'GET', option).json()).body
}
}
})
}
}
})
}
}
}
}
Expand Down
Loading

0 comments on commit 817d128

Please sign in to comment.