Skip to content

Commit

Permalink
last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pnal committed Oct 14, 2020
1 parent 85121a1 commit 9bbadb2
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ Now it is only one adapter ``GoogleTranslatorAdapter`` which uses [stichoza/goog
```yaml
App\Service\Translator\AdapterInterface:
class: App\Service\Translator\Adapter\GoogleTranslatorAdapter
```
```
## REST API
To explore API documentation you could copy [open-api.yaml](docs/open-api.yaml) content to https://editor.swagger.io/
3 changes: 0 additions & 3 deletions config/routes/dev/framework.yaml

This file was deleted.

67 changes: 67 additions & 0 deletions docs/open-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
openapi: 3.0.1
info:
title: Assessment API
description: 'Assessment API'
version: v1

paths:
/questions:
get:
summary: Returns the list of translated questions and associated choices
parameters:
- in: query
required: true
name: lang
schema:
type: string
description: Language (ISO-639-1 code) in which the questions and choices should be translated
responses:
200:
description: List of translated questions and associated choices
content:
application/json:
schema:
$ref: '#/components/schemas/QuestionList'
post:
summary: Creates a new question and associated choices (the number of associated choices must be exactly equal to 3)
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Question'
responses:
200:
description: Question and associated choices (not translated)
content:
application/json:
schema:
$ref: '#/components/schemas/Question'
components:
schemas:
QuestionList:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Question'
Question:
type: object
properties:
text:
type: string
createdAt:
type: string
format: date-time
description: Creation date of the question
choices:
type: array
description: Choices associated to the question
items:
$ref: '#/components/schemas/Choice'
Choice:
type: object
properties:
text:
type: string
1 change: 1 addition & 0 deletions src/Domain/Service/API/DTO/MultipleChoiceQuestionDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static function fromPSRRequest(RequestInterface $request)
throw new APIValidationException('Request does not contain valid JSON object');
}

// Todo check datetime and format for createdAt
foreach (static::REQUIRED_PROPS as $propName) {
if (!isset($data[$propName])) {
throw new APIValidationException(sprintf(static::MISSED_PROPERTY_ERROR_MESSAGE_TEMPLATE, $propName));
Expand Down
Empty file added tests/Integration/.gitkeep
Empty file.
Empty file added tests/Unit/.gitkeep
Empty file.

0 comments on commit 9bbadb2

Please sign in to comment.