-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
127 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: allOf-required | ||
version: 0.1.0 | ||
servers: | ||
- url: https://example.com/v1 | ||
paths: | ||
/path: | ||
get: | ||
summary: | ||
responses: | ||
'200': | ||
description: 取得成功 | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ResponseSchema' | ||
components: | ||
schemas: | ||
ResponseSchema: | ||
allOf: | ||
- required: | ||
- req_property | ||
- $ref: '#/components/schemas/BaseSchema' | ||
BaseSchema: | ||
type: object | ||
properties: | ||
req_property: | ||
type: string | ||
description: required property in response | ||
unreq_property: | ||
type: string | ||
description: unrequired property in response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { AspidaClient, BasicHeaders } from 'aspida'; | ||
import type { Methods as Methods0 } from './path'; | ||
|
||
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => { | ||
const prefix = (baseURL === undefined ? 'https://example.com/v1' : baseURL).replace(/\/$/, ''); | ||
const PATH0 = '/path'; | ||
const GET = 'GET'; | ||
|
||
return { | ||
path: { | ||
/** | ||
* @returns 取得成功 | ||
*/ | ||
get: (option?: { config?: T | undefined } | undefined) => | ||
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json(), | ||
/** | ||
* @returns 取得成功 | ||
*/ | ||
$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}`, | ||
}, | ||
}; | ||
}; | ||
|
||
export type ApiInstance = ReturnType<typeof api>; | ||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable */ | ||
export type ResponseSchema = BaseSchema | ||
|
||
export type BaseSchema = { | ||
/** required property in response */ | ||
req_property?: string | undefined | ||
/** unrequired property in response */ | ||
unreq_property?: string | undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { AspidaClient, BasicHeaders } from 'aspida'; | ||
import type { Methods as Methods0 } from '.'; | ||
|
||
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => { | ||
const prefix = (baseURL === undefined ? 'https://example.com/v1' : baseURL).replace(/\/$/, ''); | ||
const PATH0 = '/path'; | ||
const GET = 'GET'; | ||
|
||
return { | ||
/** | ||
* @returns 取得成功 | ||
*/ | ||
get: (option?: { config?: T | undefined } | undefined) => | ||
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json(), | ||
/** | ||
* @returns 取得成功 | ||
*/ | ||
$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}`, | ||
}; | ||
}; | ||
|
||
export type ApiInstance = ReturnType<typeof api>; | ||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
import type * as Types from '../@types' | ||
|
||
export type Methods = { | ||
get: { | ||
status: 200 | ||
/** 取得成功 */ | ||
resBody: Types.ResponseSchema | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters