Skip to content

Commit

Permalink
Merge pull request #27 from traPtitech/setAPI
Browse files Browse the repository at this point in the history
package.jsonの加筆
  • Loading branch information
cp-20 authored Feb 25, 2024
2 parents 64a147c + 4a5761c commit 67a7950
Show file tree
Hide file tree
Showing 6 changed files with 1,216 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dist
node_modules
node_modules
11 changes: 9 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ module.exports = {
env: {
node: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',

rules: { '@typescript-eslint/no-var-requires': 'off' },
},
{
files: ['*src/apis/openapi.ts'],
env: {
node: true,
},

rules: { '@typescript-eslint/no-explicit-any': 'off' },
},
],
reportUnusedDisableDirectives: true,
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"preview": "vite preview",
"lint": "eslint --cache .",
"format": "prettier --cache --write .",
"type-check": "vue-tsc --noEmit"
"type-check": "vue-tsc --noEmit",
"gen-api": "pnpm openapi-typescript https://raw.githubusercontent.com/traPtitech/booQ-v3/main/docs/openapi.yml --output src/apis/openapi.ts"
},
"dependencies": {
"@iconify/iconify": "^3.1.1",
"openapi-typescript-fetch": "^1.1.3",
"pinia": "^2.1.7",
"vue": "^3.4.19",
"vue-router": "^4.2.5"
Expand All @@ -27,6 +29,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.21.1",
"openapi-typescript": "^6.7.4",
"postcss": "^8.4.35",
"postcss-normalize": "^10.0.1",
"prettier": "^3.2.5",
Expand Down
71 changes: 71 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions src/apis/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import 'whatwg-fetch';

import { Fetcher } from 'openapi-typescript-fetch';

import type { paths, components } from './openapi';

// declare fetcher for paths
const fetcher = Fetcher.for<paths>();

fetcher.configure({
baseUrl: '/api',
init: {},
use: [], // middlewares
});

// create fetch operations
export const getItems = fetcher.path('/items').method('get').create();

export const getItem = fetcher.path('/items/{itemId}').method('get').create();

export const deleteItem = fetcher
.path('/items/{itemId}')
.method('delete')
.create();

export const editItem = fetcher
.path('/items/{itemId}')
.method('parameters')
.create();

export const postComment = fetcher
.path('/items/{itemId}/comments')
.method('parameters')
.create();

export const postItemOwners = fetcher
.path('/items/{itemId}/owners')
.method('post')
.create();

export const deleteItemOwners = fetcher
.path('/items/{itemId}/owners/{ownershipId}')
.method('parameters')
.create();

export const postBorrowEquipment = fetcher
.path('/items/{itemId}/borrowing/equipment')
.method('post')
.create();

export const postBorrowEquipmentReturn = fetcher
.path('/items/{itemId}/borrowing/equipment/return')
.method('post')
.create();

export const postBorrow = fetcher
.path('/items/{itemId}/owners/{ownershipId}/borrowings')
.method('post')
.create();

export const getBorrowingById = fetcher
.path('/items/{itemId}/owners/{ownershipId}/borrowings/{borrowingId}')
.method('get')
.create();

export const postBorrowReply = fetcher
.path('/items/{itemId}/owners/{ownershipId}/borrowings/{borrowingId}/reply')
.method('post')
.create();

export const postReturn = fetcher
.path('/items/{itemId}/owners/{ownershipId}/borrowings/{borrowingId}/return')
.method('post')
.create();

export const addLike = fetcher
.path('/items/{itemId}/likes')
.method('post')
.create();

export const postFile = fetcher.path('/files').method('post').create();

export const getFile = fetcher.path('/files/{fileId}').method('get').create();

export type itemPosted = components['schemas']['itemPosted'];
export type itemSummary = components['schemas']['itemSummary'];
export type comment = components['schemas']['comment'];
export type postComment = components['schemas']['postComment'];
export type transaction = components['schemas']['transaction'];
export type transactionEquipment =
components['schemas']['transactionEquipment'];
export type borrowRequest = components['schemas']['borrowRequest'];
export type borrowRequestEquipment =
components['schemas']['borrowRequestEquipment'];
export type borrowing = components['schemas']['borrowing'];
export type borrowReply = components['schemas']['itemPosted'];
export type borrowReturn = components['schemas']['borrowReturn'];
export type ownership = components['schemas']['ownership'];
export type postOwnership = components['schemas']['postOwnership'];
export type tag = components['schemas']['tag'];
export type owner = components['schemas']['owner'];
export type file = components['schemas']['file'];
Loading

0 comments on commit 67a7950

Please sign in to comment.