diff --git a/README.md b/README.md index 0f139e2..f177849 100644 --- a/README.md +++ b/README.md @@ -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 -``` \ No newline at end of file +``` + +## REST API +To explore API documentation you could copy [open-api.yaml](docs/open-api.yaml) content to https://editor.swagger.io/ \ No newline at end of file diff --git a/config/routes/dev/framework.yaml b/config/routes/dev/framework.yaml deleted file mode 100644 index bcbbf13..0000000 --- a/config/routes/dev/framework.yaml +++ /dev/null @@ -1,3 +0,0 @@ -_errors: - resource: '@FrameworkBundle/Resources/config/routing/errors.xml' - prefix: /_error diff --git a/docs/open-api.yaml b/docs/open-api.yaml new file mode 100644 index 0000000..d2aa10e --- /dev/null +++ b/docs/open-api.yaml @@ -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 \ No newline at end of file diff --git a/src/Domain/Service/API/DTO/MultipleChoiceQuestionDTO.php b/src/Domain/Service/API/DTO/MultipleChoiceQuestionDTO.php index d18c130..aa5e395 100644 --- a/src/Domain/Service/API/DTO/MultipleChoiceQuestionDTO.php +++ b/src/Domain/Service/API/DTO/MultipleChoiceQuestionDTO.php @@ -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)); diff --git a/tests/Integration/.gitkeep b/tests/Integration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Unit/.gitkeep b/tests/Unit/.gitkeep new file mode 100644 index 0000000..e69de29