Browse Source

интеграция с api

pull/1/head
Sergey Verevkin 4 years ago
parent
commit
ce1ae9bdbd
  1. 7
      README.md
  2. 158
      public/swagger.json
  3. 6
      src/components/App/App.css
  4. 6
      src/components/App/App.tsx
  5. 11
      src/components/GamePage/GamePage.tsx

7
README.md

@ -2,9 +2,10 @@
ООП игра Яга для тренировки ПИб-201 и ПИб-202 КузГТУ
Игра работает с локальным сервером, который Вы сами напишете.
Требования к api:
- реализация _./swagger_file_
Игра работает с локальным сервером, который Вы сами напишете. Требования к api:
- реализация http://ooya.ga/swagger.json
- хостинг https://localhost:7115/api/v1
- CORS должен принимать любые домены
## Удачи!

158
public/swagger.json

@ -0,0 +1,158 @@
{
"openapi": "3.0.1",
"info": {
"title": "ooya.ga_api",
"version": "1.0"
},
"paths": {
"/api/v1/version": {
"get": {
"tags": [
"Api"
],
"operationId": "version",
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
},
"application/json": {
"schema": {
"type": "string"
}
},
"text/json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/api/v1/game": {
"get": {
"tags": [
"Api"
],
"operationId": "game",
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/GameDto"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/GameDto"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/GameDto"
}
}
}
}
}
}
},
"/api/v1/turn": {
"get": {
"tags": [
"Api"
],
"operationId": "turn",
"parameters": [
{
"name": "gameGuid",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "witchGuid",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/GameDto"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/GameDto"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/GameDto"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GameDto": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"guid": {
"type": "string",
"nullable": true
},
"score": {
"type": "integer",
"format": "int32"
},
"witches": {
"type": "array",
"items": {
"$ref": "#/components/schemas/WitchDto"
},
"nullable": true
}
},
"additionalProperties": false
},
"WitchDto": {
"type": "object",
"properties": {
"guid": {
"type": "string",
"nullable": true
},
"position": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
}
}
}
}

6
src/components/App/App.css

@ -41,6 +41,12 @@ h1 {
.small {
font-size: 0.5em;
text-align: left;
}
.small a, .small a:visited, .small a:active {
color: white;
text-decoration: underline;
}
.witch {

6
src/components/App/App.tsx

@ -21,18 +21,20 @@ const App: React.FC<AppProps> = observer((props) => {
case EGameStage.Start: {
content = <IntroPage onEnterGame={() => {
apiStore.startNewGame();
} } />;
}}/>;
break;
}
case EGameStage.Process: {
content = <GamePage onExitGame={() => apiStore.setGameStage(EGameStage.Start) } />;
content = <GamePage onExitGame={() => apiStore.setGameStage(EGameStage.Start)}/>;
break;
}
}
return (
<>
<div className="App">
{content}
</div>
</>
);
});

11
src/components/GamePage/GamePage.tsx

@ -59,7 +59,16 @@ const GamePage: React.FC<GameProps> = (props) => {
checked={!apiStore.mockMode}
value='1'
onChange={(e) => apiStore.tryToSetMockMode(e.target.checked)}
/></div>
/>
</div>
<div className="small">Свой сервис:
<ul>
<li>реализация <a href="/swagger.json">swagger</a></li>
<li>хостинг https://localhost:7115/api/v1</li>
<li>прием CORS от ooya.ga</li>
</ul>
</div>
</header>
);
}

Loading…
Cancel
Save