|
| 1 | +/* eslint-disable */ |
| 2 | +import { AspidaClient, BasicHeaders, dataToURLString } from 'aspida' |
| 3 | +import * as ApiTypes from './@types' |
| 4 | +import { Methods as Methods0 } from '.' |
| 5 | +import { Methods as Methods1 } from './_sampleId.json@number' |
| 6 | +import { Methods as Methods2 } from './v1.1' |
| 7 | +import { Methods as Methods3 } from './v1.1/2/_hogeId@HogeId/entries.json' |
| 8 | +import { Methods as Methods4 } from './v1.1/2/_hogeId@HogeId/test-4' |
| 9 | +import { Methods as Methods5 } from './v1.1/2/_hogeId@HogeId/test-4/_fugaId' |
| 10 | +import { Methods as Methods6 } from './v1.1/2/_hogeId@HogeId/test-4/fuga aa' |
| 11 | +import { Methods as Methods7 } from './v1.1/2/_hogeId@number' |
| 12 | +import { Methods as Methods8 } from './v1.1/3.1' |
| 13 | +import { Methods as Methods9 } from './v1.1/_articleId.json' |
| 14 | +import { Methods as Methods10 } from './v1.1/users/_userId@User[\'id\']' |
| 15 | +import { Methods as Methods11 } from './v2.0' |
| 16 | + |
| 17 | +const api = <T>({ baseURL, fetch }: AspidaClient<T>) => { |
| 18 | + const prefix = (baseURL === undefined ? 'https://example.com/api/' : baseURL).replace(/\/$/, '') |
| 19 | + const PATH0 = '/v1.1' |
| 20 | + const PATH1 = '/v1.1/2' |
| 21 | + const PATH2 = '/entries.json' |
| 22 | + const PATH3 = '/test-4' |
| 23 | + const PATH4 = '/test-4/fuga aa' |
| 24 | + const PATH5 = '/v1.1/3.1' |
| 25 | + const PATH6 = '/v1.1/users' |
| 26 | + const PATH7 = '/v2.0' |
| 27 | + const GET = 'GET' |
| 28 | + const POST = 'POST' |
| 29 | + const PUT = 'PUT' |
| 30 | + const DELETE = 'DELETE' |
| 31 | + |
| 32 | + return { |
| 33 | + _sampleId_json: (val0: number) => { |
| 34 | + const prefix0 = `/${val0}.json` |
| 35 | + |
| 36 | + return { |
| 37 | + get: (option?: { config?: T }) => |
| 38 | + fetch<Methods1['get']['resBody']>(prefix, prefix0, GET, option).json(), |
| 39 | + $get: (option?: { config?: T }) => |
| 40 | + fetch<Methods1['get']['resBody']>(prefix, prefix0, GET, option).json().then(r => r.body), |
| 41 | + $path: () => `${prefix}${prefix0}` |
| 42 | + } |
| 43 | + }, |
| 44 | + v1_1: { |
| 45 | + $2: { |
| 46 | + _hogeId_0: (val1: ApiTypes.HogeId) => { |
| 47 | + const prefix1 = `${PATH1}/${val1}` |
| 48 | + |
| 49 | + return { |
| 50 | + entries_json: { |
| 51 | + get: (option?: { config?: T }) => |
| 52 | + fetch<Methods3['get']['resBody']>(prefix, `${prefix1}${PATH2}`, GET, option).json(), |
| 53 | + $get: (option?: { config?: T }) => |
| 54 | + fetch<Methods3['get']['resBody']>(prefix, `${prefix1}${PATH2}`, GET, option).json().then(r => r.body), |
| 55 | + $path: () => `${prefix}${prefix1}${PATH2}` |
| 56 | + }, |
| 57 | + test_4: { |
| 58 | + _fugaId: (val2: number | string) => { |
| 59 | + const prefix2 = `${prefix1}${PATH3}/${val2}` |
| 60 | + |
| 61 | + return { |
| 62 | + get: (option?: { query?: Methods5['get']['query'], config?: T }) => |
| 63 | + fetch<Methods5['get']['resBody']>(prefix, prefix2, GET, option).json(), |
| 64 | + $get: (option?: { query?: Methods5['get']['query'], config?: T }) => |
| 65 | + fetch<Methods5['get']['resBody']>(prefix, prefix2, GET, option).json().then(r => r.body), |
| 66 | + post: (option: { body?: Methods5['post']['reqBody'], query: Methods5['post']['query'], config?: T }) => |
| 67 | + fetch<Methods5['post']['resBody']>(prefix, prefix2, POST, option).json(), |
| 68 | + $post: (option: { body?: Methods5['post']['reqBody'], query: Methods5['post']['query'], config?: T }) => |
| 69 | + fetch<Methods5['post']['resBody']>(prefix, prefix2, POST, option).json().then(r => r.body), |
| 70 | + put: (option: { query: Methods5['put']['query'], config?: T }) => |
| 71 | + fetch<Methods5['put']['resBody']>(prefix, prefix2, PUT, option).json(), |
| 72 | + $put: (option: { query: Methods5['put']['query'], config?: T }) => |
| 73 | + fetch<Methods5['put']['resBody']>(prefix, prefix2, PUT, option).json().then(r => r.body), |
| 74 | + delete: (option: { query: Methods5['delete']['query'], config?: T }) => |
| 75 | + fetch<Methods5['delete']['resBody']>(prefix, prefix2, DELETE, option).json(), |
| 76 | + $delete: (option: { query: Methods5['delete']['query'], config?: T }) => |
| 77 | + fetch<Methods5['delete']['resBody']>(prefix, prefix2, DELETE, option).json().then(r => r.body), |
| 78 | + $path: (option?: { method?: 'get'; query: Methods5['get']['query'] } | { method: 'post'; query: Methods5['post']['query'] } | { method: 'put'; query: Methods5['put']['query'] } | { method: 'delete'; query: Methods5['delete']['query'] }) => |
| 79 | + `${prefix}${prefix2}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 80 | + } |
| 81 | + }, |
| 82 | + fuga_aa: { |
| 83 | + get: (option: { query: Methods6['get']['query'], config?: T }) => |
| 84 | + fetch<Methods6['get']['resBody']>(prefix, `${prefix1}${PATH4}`, GET, option).json(), |
| 85 | + $get: (option: { query: Methods6['get']['query'], config?: T }) => |
| 86 | + fetch<Methods6['get']['resBody']>(prefix, `${prefix1}${PATH4}`, GET, option).json().then(r => r.body), |
| 87 | + post: (option: { body?: Methods6['post']['reqBody'], query: Methods6['post']['query'], config?: T }) => |
| 88 | + fetch<Methods6['post']['resBody']>(prefix, `${prefix1}${PATH4}`, POST, option).json(), |
| 89 | + $post: (option: { body?: Methods6['post']['reqBody'], query: Methods6['post']['query'], config?: T }) => |
| 90 | + fetch<Methods6['post']['resBody']>(prefix, `${prefix1}${PATH4}`, POST, option).json().then(r => r.body), |
| 91 | + put: (option: { query: Methods6['put']['query'], config?: T }) => |
| 92 | + fetch<Methods6['put']['resBody']>(prefix, `${prefix1}${PATH4}`, PUT, option).json(), |
| 93 | + $put: (option: { query: Methods6['put']['query'], config?: T }) => |
| 94 | + fetch<Methods6['put']['resBody']>(prefix, `${prefix1}${PATH4}`, PUT, option).json().then(r => r.body), |
| 95 | + delete: (option: { body: Methods6['delete']['reqBody'], query: Methods6['delete']['query'], config?: T }) => |
| 96 | + fetch<Methods6['delete']['resBody']>(prefix, `${prefix1}${PATH4}`, DELETE, option).json(), |
| 97 | + $delete: (option: { body: Methods6['delete']['reqBody'], query: Methods6['delete']['query'], config?: T }) => |
| 98 | + fetch<Methods6['delete']['resBody']>(prefix, `${prefix1}${PATH4}`, DELETE, option).json().then(r => r.body), |
| 99 | + $path: (option?: { method?: 'get'; query: Methods6['get']['query'] } | { method: 'post'; query: Methods6['post']['query'] } | { method: 'put'; query: Methods6['put']['query'] } | { method: 'delete'; query: Methods6['delete']['query'] }) => |
| 100 | + `${prefix}${prefix1}${PATH4}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 101 | + }, |
| 102 | + get: (option: { query: Methods4['get']['query'], config?: T }) => |
| 103 | + fetch<void>(prefix, `${prefix1}${PATH3}`, GET, option).send(), |
| 104 | + $get: (option: { query: Methods4['get']['query'], config?: T }) => |
| 105 | + fetch<void>(prefix, `${prefix1}${PATH3}`, GET, option).send().then(r => r.body), |
| 106 | + post: (option?: { body?: Methods4['post']['reqBody'], query?: Methods4['post']['query'], config?: T }) => |
| 107 | + fetch<void>(prefix, `${prefix1}${PATH3}`, POST, option).send(), |
| 108 | + $post: (option?: { body?: Methods4['post']['reqBody'], query?: Methods4['post']['query'], config?: T }) => |
| 109 | + fetch<void>(prefix, `${prefix1}${PATH3}`, POST, option).send().then(r => r.body), |
| 110 | + put: (option?: { query?: Methods4['put']['query'], config?: T }) => |
| 111 | + fetch<Methods4['put']['resBody']>(prefix, `${prefix1}${PATH3}`, PUT, option).json(), |
| 112 | + $put: (option?: { query?: Methods4['put']['query'], config?: T }) => |
| 113 | + fetch<Methods4['put']['resBody']>(prefix, `${prefix1}${PATH3}`, PUT, option).json().then(r => r.body), |
| 114 | + delete: (option: { query: Methods4['delete']['query'], config?: T }) => |
| 115 | + fetch<Methods4['delete']['resBody']>(prefix, `${prefix1}${PATH3}`, DELETE, option).json(), |
| 116 | + $delete: (option: { query: Methods4['delete']['query'], config?: T }) => |
| 117 | + fetch<Methods4['delete']['resBody']>(prefix, `${prefix1}${PATH3}`, DELETE, option).json().then(r => r.body), |
| 118 | + $path: (option?: { method?: 'get'; query: Methods4['get']['query'] } | { method: 'post'; query: Methods4['post']['query'] } | { method: 'put'; query: Methods4['put']['query'] } | { method: 'delete'; query: Methods4['delete']['query'] }) => |
| 119 | + `${prefix}${prefix1}${PATH3}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 120 | + } |
| 121 | + } |
| 122 | + }, |
| 123 | + _hogeId_1: (val3: number) => { |
| 124 | + const prefix3 = `${PATH1}/${val3}` |
| 125 | + |
| 126 | + return { |
| 127 | + get: (option: { query?: Methods7['get']['query'], headers: Methods7['get']['reqHeaders'], config?: T }) => |
| 128 | + fetch<Methods7['get']['resBody']>(prefix, prefix3, GET, option).json(), |
| 129 | + $get: (option: { query?: Methods7['get']['query'], headers: Methods7['get']['reqHeaders'], config?: T }) => |
| 130 | + fetch<Methods7['get']['resBody']>(prefix, prefix3, GET, option).json().then(r => r.body), |
| 131 | + $path: (option?: { method?: 'get'; query: Methods7['get']['query'] }) => |
| 132 | + `${prefix}${prefix3}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 133 | + } |
| 134 | + } |
| 135 | + }, |
| 136 | + $3_1: { |
| 137 | + get: (option: { query?: Methods8['get']['query'], headers: Methods8['get']['reqHeaders'], config?: T }) => |
| 138 | + fetch<Methods8['get']['resBody']>(prefix, PATH5, GET, option).json(), |
| 139 | + $get: (option: { query?: Methods8['get']['query'], headers: Methods8['get']['reqHeaders'], config?: T }) => |
| 140 | + fetch<Methods8['get']['resBody']>(prefix, PATH5, GET, option).json().then(r => r.body), |
| 141 | + post: (option: { body?: Methods8['post']['reqBody'], query: Methods8['post']['query'], config?: T }) => |
| 142 | + fetch<Methods8['post']['resBody']>(prefix, PATH5, POST, option, 'URLSearchParams').json(), |
| 143 | + $post: (option: { body?: Methods8['post']['reqBody'], query: Methods8['post']['query'], config?: T }) => |
| 144 | + fetch<Methods8['post']['resBody']>(prefix, PATH5, POST, option, 'URLSearchParams').json().then(r => r.body), |
| 145 | + $path: (option?: { method?: 'get'; query: Methods8['get']['query'] } | { method: 'post'; query: Methods8['post']['query'] }) => |
| 146 | + `${prefix}${PATH5}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 147 | + }, |
| 148 | + _articleId_json: (val4: number | string) => { |
| 149 | + const prefix4 = `${PATH0}/${val4}.json` |
| 150 | + |
| 151 | + return { |
| 152 | + get: (option?: { config?: T }) => |
| 153 | + fetch<Methods9['get']['resBody']>(prefix, prefix4, GET, option).json(), |
| 154 | + $get: (option?: { config?: T }) => |
| 155 | + fetch<Methods9['get']['resBody']>(prefix, prefix4, GET, option).json().then(r => r.body), |
| 156 | + $path: () => `${prefix}${prefix4}` |
| 157 | + } |
| 158 | + }, |
| 159 | + users: { |
| 160 | + _userId: (val5: ApiTypes.User['id']) => { |
| 161 | + const prefix5 = `${PATH6}/${val5}` |
| 162 | + |
| 163 | + return { |
| 164 | + get: (option: { query: Methods10['get']['query'], headers: Methods10['get']['reqHeaders'], config?: T }) => |
| 165 | + fetch<Methods10['get']['resBody']>(prefix, prefix5, GET, option).json(), |
| 166 | + $get: (option: { query: Methods10['get']['query'], headers: Methods10['get']['reqHeaders'], config?: T }) => |
| 167 | + fetch<Methods10['get']['resBody']>(prefix, prefix5, GET, option).json().then(r => r.body), |
| 168 | + post: (option: { query: Methods10['post']['query'], config?: T }) => |
| 169 | + fetch<Methods10['post']['resBody']>(prefix, prefix5, POST, option).json(), |
| 170 | + $post: (option: { query: Methods10['post']['query'], config?: T }) => |
| 171 | + fetch<Methods10['post']['resBody']>(prefix, prefix5, POST, option).json().then(r => r.body), |
| 172 | + $path: (option?: { method?: 'get'; query: Methods10['get']['query'] } | { method: 'post'; query: Methods10['post']['query'] }) => |
| 173 | + `${prefix}${prefix5}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 174 | + } |
| 175 | + } |
| 176 | + }, |
| 177 | + get: (option?: { query?: Methods2['get']['query'], config?: T }) => |
| 178 | + fetch<Methods2['get']['resBody'], BasicHeaders, Methods2['get']['status']>(prefix, PATH0, GET, option).json(), |
| 179 | + $get: (option?: { query?: Methods2['get']['query'], config?: T }) => |
| 180 | + fetch<Methods2['get']['resBody'], BasicHeaders, Methods2['get']['status']>(prefix, PATH0, GET, option).json().then(r => r.body), |
| 181 | + $path: (option?: { method?: 'get'; query: Methods2['get']['query'] }) => |
| 182 | + `${prefix}${PATH0}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 183 | + }, |
| 184 | + v2_0: { |
| 185 | + get: (option: { query: Methods11['get']['query'], headers: Methods11['get']['reqHeaders'], config?: T }) => |
| 186 | + fetch<Methods11['get']['resBody'], Methods11['get']['resHeaders'], Methods11['get']['status']>(prefix, PATH7, GET, option).text(), |
| 187 | + $get: (option: { query: Methods11['get']['query'], headers: Methods11['get']['reqHeaders'], config?: T }) => |
| 188 | + fetch<Methods11['get']['resBody'], Methods11['get']['resHeaders'], Methods11['get']['status']>(prefix, PATH7, GET, option).text().then(r => r.body), |
| 189 | + $path: (option?: { method?: 'get'; query: Methods11['get']['query'] }) => |
| 190 | + `${prefix}${PATH7}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 191 | + }, |
| 192 | + get: (option?: { query?: Methods0['get']['query'], headers?: Methods0['get']['reqHeaders'], config?: T }) => |
| 193 | + fetch<Methods0['get']['resBody']>(prefix, '', GET, option).formData(), |
| 194 | + $get: (option?: { query?: Methods0['get']['query'], headers?: Methods0['get']['reqHeaders'], config?: T }) => |
| 195 | + fetch<Methods0['get']['resBody']>(prefix, '', GET, option).formData().then(r => r.body), |
| 196 | + post: (option: { body: Methods0['post']['reqBody'], query: Methods0['post']['query'], headers?: Methods0['post']['reqHeaders'], config?: T }) => |
| 197 | + fetch<Methods0['post']['resBody']>(prefix, '', POST, option).arrayBuffer(), |
| 198 | + $post: (option: { body: Methods0['post']['reqBody'], query: Methods0['post']['query'], headers?: Methods0['post']['reqHeaders'], config?: T }) => |
| 199 | + fetch<Methods0['post']['resBody']>(prefix, '', POST, option).arrayBuffer().then(r => r.body), |
| 200 | + put: (option: { query: Methods0['put']['query'], config?: T }) => |
| 201 | + fetch<Methods0['put']['resBody'], Methods0['put']['resHeaders'], Methods0['put']['status']>(prefix, '', PUT, option).json(), |
| 202 | + $put: (option: { query: Methods0['put']['query'], config?: T }) => |
| 203 | + fetch<Methods0['put']['resBody'], Methods0['put']['resHeaders'], Methods0['put']['status']>(prefix, '', PUT, option).json().then(r => r.body), |
| 204 | + delete: (option: { query: Methods0['delete']['query'], config?: T }) => |
| 205 | + fetch<void, Methods0['delete']['resHeaders'], Methods0['delete']['status']>(prefix, '', DELETE, option).send(), |
| 206 | + $delete: (option: { query: Methods0['delete']['query'], config?: T }) => |
| 207 | + fetch<void, Methods0['delete']['resHeaders'], Methods0['delete']['status']>(prefix, '', DELETE, option).send().then(r => r.body), |
| 208 | + $path: (option?: { method?: 'get'; query: Methods0['get']['query'] } | { method: 'post'; query: Methods0['post']['query'] } | { method: 'put'; query: Methods0['put']['query'] } | { method: 'delete'; query: Methods0['delete']['query'] }) => |
| 209 | + `${prefix}${''}${option?.query ? `?${dataToURLString(option.query)}` : ''}` |
| 210 | + } |
| 211 | +} |
| 212 | + |
| 213 | +export type ApiInstance = ReturnType<typeof api> |
| 214 | +export default api |
0 commit comments