Skip to content

Commit

Permalink
Merge pull request #47 from traP-jp/feat/#46-generate-api-v1.0.1
Browse files Browse the repository at this point in the history
✨ generated openapi code
  • Loading branch information
comavius authored Oct 4, 2024
2 parents cc3d8a7 + 44ecfa2 commit 9a7c38a
Show file tree
Hide file tree
Showing 35 changed files with 2,734 additions and 0 deletions.
3 changes: 3 additions & 0 deletions judge-control-app/backend-api-schema/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock
23 changes: 23 additions & 0 deletions judge-control-app/backend-api-schema/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
18 changes: 18 additions & 0 deletions judge-control-app/backend-api-schema/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.gitignore
.openapi-generator-ignore
.travis.yml
Cargo.toml
README.md
docs/JudgeStatus.md
docs/SubmitResult.md
docs/SubmitResultApi.md
docs/TestResult.md
git_push.sh
src/apis/configuration.rs
src/apis/mod.rs
src/apis/submit_result_api.rs
src/lib.rs
src/models/judge_status.rs
src/models/mod.rs
src/models/submit_result.rs
src/models/test_result.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.9.0-SNAPSHOT
1 change: 1 addition & 0 deletions judge-control-app/backend-api-schema/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: rust
15 changes: 15 additions & 0 deletions judge-control-app/backend-api-schema/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "backend_api_schema"
version = "0.1.0"
authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
license = "MIT"
edition = "2021"

[dependencies]
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
serde_repr = "^0.1"
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
reqwest = { version = "^0.12", features = ["json", "multipart"] }
48 changes: 48 additions & 0 deletions judge-control-app/backend-api-schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Rust API client for backend_api_schema

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)


## Overview

This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.

- API version: 0.1
- Package version: 0.1
- Generator version: 7.9.0-SNAPSHOT
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`

## Installation

Put the package under your project folder in a directory named `backend_api_schema` and add the following to `Cargo.toml` under `[dependencies]`:

```
backend_api_schema = { path = "./backend_api_schema" }
```

## Documentation for API Endpoints

All URIs are relative to *https://api.server.test/v1*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*SubmitResultApi* | [**submit_result**](docs/SubmitResultApi.md#submit_result) | **POST** /submit-result | 通常のテストケースのジャッジ


## Documentation For Models

- [JudgeStatus](docs/JudgeStatus.md)
- [SubmitResult](docs/SubmitResult.md)
- [TestResult](docs/TestResult.md)


To get access to the crate's generated documentation, use:

```
cargo doc --open
```

## Author



99 changes: 99 additions & 0 deletions judge-control-app/backend-api-schema/backend-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
openapi: '3.0.3'
info:
title: Backend to Judge API
version: '0.1'
license:
name: MIT
url: 'https://github.com/traP-jp/traO-Judge-docs/blob/main/LICENSE'
servers:
- url: https://api.server.test/v1
paths:
'/submit-result':
post:
operationId: submitResult
description: ジャッジ結果
tags:
- submit result
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubmitResult'
required: true
summary: 通常のテストケースのジャッジ
responses:
'200':
description: OK

components:
schemas:
JudgeStatus:
title: JudgeStatus
type: string
description: ジャッジの結果
enum:
- AC
- WA
- TLE
- MLE
- OLE
- RE
- CE
- IE
TestResult:
title: TestResult
type: object
description: テストケースの結果
properties:
status:
title: status
$ref: '#/components/schemas/JudgeStatus'
text:
title: text
type: string
description: 追加情報
example: 'Alice win'
score:
title: score
type: number
description: スコア
example: 100
execTime:
title: execTime
type: number
description: 実行時間
example: 1.23
memorySize:
title: memorySize
type: number
description: メモリ使用量(byte)
example: 1234567
required:
- status
- score
- execTime
- memorySize
SubmitResult:
type: object
title: JudgeResult
description: テストケースのジャッジ結果
properties:
judgeId:
title: judgeId
type: string
description: ジャッジID
format: uuid
example: 01234567-89ab-cdef-0123-456789abcdef
testResults:
title: testResults
type: array
description: テストケースのリスト
items:
$ref: '#/components/schemas/TestResult'
totalResult:
title: totalResult
$ref: '#/components/schemas/TestResult'
required:
- judgeId
- testResults
- totalResult
19 changes: 19 additions & 0 deletions judge-control-app/backend-api-schema/docs/JudgeStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# JudgeStatus

## Enum Variants

| Name | Value |
|---- | -----|
| Ac | AC |
| Wa | WA |
| Tle | TLE |
| Mle | MLE |
| Ole | OLE |
| Re | RE |
| Ce | CE |
| Ie | IE |


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


13 changes: 13 additions & 0 deletions judge-control-app/backend-api-schema/docs/SubmitResult.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SubmitResult

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**judge_id** | [**uuid::Uuid**](uuid::Uuid.md) | ジャッジID |
**test_results** | [**Vec<models::TestResult>**](TestResult.md) | テストケースのリスト |
**total_result** | [**models::TestResult**](TestResult.md) | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


39 changes: 39 additions & 0 deletions judge-control-app/backend-api-schema/docs/SubmitResultApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# \SubmitResultApi

All URIs are relative to *https://api.server.test/v1*

Method | HTTP request | Description
------------- | ------------- | -------------
[**submit_result**](SubmitResultApi.md#submit_result) | **POST** /submit-result | 通常のテストケースのジャッジ



## submit_result

> submit_result(submit_result)
通常のテストケースのジャッジ

ジャッジ結果

### Parameters


Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**submit_result** | [**SubmitResult**](SubmitResult.md) | | [required] |

### Return type

(empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

15 changes: 15 additions & 0 deletions judge-control-app/backend-api-schema/docs/TestResult.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# TestResult

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**status** | [**models::JudgeStatus**](JudgeStatus.md) | |
**text** | Option<**String**> | 追加情報 | [optional]
**score** | **f64** | スコア |
**exec_time** | **f64** | 実行時間 |
**memory_size** | **f64** | メモリ使用量(byte) |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


57 changes: 57 additions & 0 deletions judge-control-app/backend-api-schema/git_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"

git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4

if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi

if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi

if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi

# Initialize the local directory as a Git repository
git init

# Adds the files in the local repository and stages them for commit.
git add .

# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"

# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi

fi

git pull origin master

# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
Loading

0 comments on commit 9a7c38a

Please sign in to comment.