Skip to content

Commit

Permalink
Merge pull request #151 from aspida/develop
Browse files Browse the repository at this point in the history
chore(release): 0.16.5
  • Loading branch information
solufa authored Jul 22, 2021
2 parents 94ccec9 + 15c0caa commit 8a33eca
Show file tree
Hide file tree
Showing 17 changed files with 1,629 additions and 1,953 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
external_refs_sample
samples
dist
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [10, 12, 14]
node-version: [12, 14, 16]
os: [ubuntu-latest]
include:
- os: windows-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules
dist
external_refs_sample
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
samples
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint"]
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
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.16.5](https://github.com/aspida/openapi2aspida/compare/v0.16.4...v0.16.5) (2021-07-22)


### Bug Fixes

* array one of ([955105f](https://github.com/aspida/openapi2aspida/commit/955105f3c5b4b91d8db5a004c9a61487d21598fd))

### [0.16.4](https://github.com/aspida/openapi2aspida/compare/v0.16.3...v0.16.4) (2021-05-15)


Expand Down
5 changes: 5 additions & 0 deletions aspida.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ module.exports = [
input: 'samples/nullable-object',
outputEachDir: true,
openapi: { inputFile: 'samples/nullable-object.yml' }
},
{
input: 'samples/array-one-of',
outputEachDir: true,
openapi: { inputFile: 'samples/array-one-of.yml' }
}
]
6 changes: 5 additions & 1 deletion jest.config.js → jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
import type { Config } from '@jest/types'

const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['samples'],
coveragePathIgnorePatterns: ['samples', 'dist']
}

export default config
43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openapi2aspida",
"version": "0.16.4",
"version": "0.16.5",
"description": "Convert OpenAPI 3.0 or Swagger 2.0 definitions into aspida",
"author": "Solufa <[email protected]>",
"license": "MIT",
Expand All @@ -14,8 +14,8 @@
"release:major": "npm run release -- --release-as major",
"release:minor": "npm run release -- --release-as minor",
"release:patch": "npm run release -- --release-as patch",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "npm run lint -- --fix",
"lint": "eslint --ext .ts . && prettier --check \"./**/*.ts\"",
"lint:fix": "eslint --ext .ts . --fix && prettier --write \"./**/*.ts\"",
"test": "jest",
"typecheck": "tsc --noEmit"
},
Expand Down Expand Up @@ -46,7 +46,6 @@
"standard",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended",
"prettier"
],
"parserOptions": {
Expand Down Expand Up @@ -84,31 +83,31 @@
]
},
"dependencies": {
"aspida": "^1.7.0",
"aspida": "^1.7.1",
"js-yaml": "^4.1.0",
"openapi-types": "^8.0.0",
"openapi-types": "^9.1.0",
"swagger-parser": "^10.0.2",
"swagger2openapi": "^7.0.5"
"swagger2openapi": "^7.0.8"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/js-yaml": "^4.0.1",
"@types/minimist": "^1.2.1",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"eslint": "^7.26.0",
"@types/jest": "^26.0.24",
"@types/js-yaml": "^4.0.2",
"@types/minimist": "^1.2.2",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.6",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"jest": "^26.6.3",
"prettier": "^2.3.0",
"standard-version": "^9.3.0",
"ts-jest": "^26.5.6",
"typescript": "^4.2.4"
"jest": "^27.0.6",
"prettier": "^2.3.2",
"standard-version": "^9.3.1",
"ts-jest": "^27.0.4",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
}
}
44 changes: 44 additions & 0 deletions samples/array-one-of.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
openapi: 3.0.0
info:
version: "1.0.0"
title: "Sample"
paths:
/user:
get:
responses:
"200":
description: "sample"
content:
application/json:
schema:
type: object
properties:
user:
nullable: true
anyOf:
- $ref: "#/components/schemas/User"
components:
schemas:
User:
type: object
properties:
id:
type: string
roles:
type: array
items:
oneOf:
- $ref: "#/components/schemas/RoleA"
- $ref: "#/components/schemas/RoleB"
RoleA:
type: object
properties:
name:
type: string
RoleB:
type: object
properties:
name:
type: string
authority:
type: string
33 changes: 33 additions & 0 deletions samples/array-one-of/$api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* eslint-disable */
// prettier-ignore
import { AspidaClient, BasicHeaders } from 'aspida'
// prettier-ignore
import { Methods as Methods0 } from './user'

// prettier-ignore
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
const prefix = (baseURL === undefined ? '' : baseURL).replace(/\/$/, '')
const PATH0 = '/user'
const GET = 'GET'

return {
user: {
/**
* @returns sample
*/
get: (option?: { config?: T }) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json(),
/**
* @returns sample
*/
$get: (option?: { config?: T }) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH0}`
}
}
}

// prettier-ignore
export type ApiInstance = ReturnType<typeof api>
// prettier-ignore
export default api
14 changes: 14 additions & 0 deletions samples/array-one-of/@types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable */
export type User = {
id: string
roles: (RoleA | RoleB)[]
}

export type RoleA = {
name: string
}

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

// prettier-ignore
const api = <T>({ baseURL, fetch }: AspidaClient<T>) => {
const prefix = (baseURL === undefined ? '' : baseURL).replace(/\/$/, '')
const PATH0 = '/user'
const GET = 'GET'

return {
/**
* @returns sample
*/
get: (option?: { config?: T }) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json(),
/**
* @returns sample
*/
$get: (option?: { config?: T }) =>
fetch<Methods0['get']['resBody'], BasicHeaders, Methods0['get']['status']>(prefix, PATH0, GET, option).json().then(r => r.body),
$path: () => `${prefix}${PATH0}`
}
}

// prettier-ignore
export type ApiInstance = ReturnType<typeof api>
// prettier-ignore
export default api
13 changes: 13 additions & 0 deletions samples/array-one-of/user/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable */
import type * as Types from '../@types'

export type Methods = {
get: {
status: 200

/** sample */
resBody: {
user: Partial<Types.User> | null
}
}
}
2 changes: 1 addition & 1 deletion src/buildV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default (openapi: OpenAPIV3.Document) => {
]
.map(p => `\n${description2Doc(p.description, '')}export type ${p.name} = ${p.text}\n`)
.join('')
.replace(/ Types\./g, ' ')
.replace(/(\W)Types\./g, '$1')
: null

return {
Expand Down
Loading

0 comments on commit 8a33eca

Please sign in to comment.