Files
lincodex/api/core/routes/candidate_questionnaire.yml

85 lines
5.3 KiB
YAML

get:
operationId: GetMyQuestionnaire
summary: Read the questionnaire of the current candidate.
description: |-
Requires the session cookie of a candidate account. The candidate comes from the session, never from a request parameter. A candidate who has not saved the questionnaire yet gets 200 with version 0 and no specializations rather than 404, so the client reads the version for the first save in the same way as for later ones and a missing questionnaire is not an error state.
The response never contains a confirmed grade or a category; those come only from assessment results. A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden.
security:
- sessionCookie: []
tags:
- candidate
responses:
"200":
description: The questionnaire of the current candidate.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/CandidateQuestionnaire
examples:
new_candidate:
$ref: ../components/examples.yml#/NewCandidateQuestionnaire
backend_go_and_network_engineer:
$ref: ../components/examples.yml#/BackendGoAndNetworkEngineerQuestionnaire
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
put:
operationId: SaveMyQuestionnaire
summary: Replace the questionnaire of the current candidate.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body is the complete new state: one or two specializations, each with a self-assessed grade, task languages, stack tags, and stated experience or null, and the working context. It replaces the stored questionnaire as a whole.
Self-assessment is a claim. It influences where the assessment starts and which grade the assessment step offers first, but it adds no points and never writes a confirmed grade or a category: a self-assessed `senior`, or the word "Senior" in a stack tag, never assigns the Senior category. A real profile stays invisible to employers until an assessment confirms a category. Choosing a specialization whose test is `in_development` is allowed; no assessment starts for it until its bank is published. Removing a specialization from the questionnaire does not change assessment results.
Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read, 0 for the first save. If it is not the current version, the server answers 412 version_conflict and changes nothing; the client reads the questionnaire again. The version travels in the body rather than in If-Match because the generated client cannot read the ETag response header yet. The status and code are the same as for a failed If-Match, since the client action is the same.
The operation needs no Idempotency-Key: it replaces the whole state and is idempotent. A body whose specializations and working context equal the stored ones changes nothing, keeps the version, and answers 200 with the current questionnaire even when `expected_version` is older, so a retry after a lost response of a successful save succeeds instead of failing with 412.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for an employer), domain rules (400), then the version (412). The schema rejects more than two specializations, an unknown grade, specialization, or task language, and unknown fields. The server also rejects a repeated specialization and a task language that the specialization's published bank does not offer, with 400 validation_failed and pointers to the items, for example `/specializations/1/specialization` or `/specializations/0/task_languages/0`.
A successful save on the onboarding step candidate_questionnaire advances the account to candidate_assessment (planned).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- candidate
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/CandidateQuestionnaireUpdate
examples:
backend_go_and_network_engineer:
$ref: ../components/examples.yml#/BackendGoAndNetworkEngineerQuestionnaireUpdate
responses:
"200":
description: The saved questionnaire with its new version.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/CandidateQuestionnaire
examples:
backend_go_and_network_engineer:
$ref: ../components/examples.yml#/BackendGoAndNetworkEngineerQuestionnaire
"400":
$ref: ../components/responses.yml#/QuestionnaireValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"412":
$ref: ../components/responses.yml#/QuestionnaireVersionConflict
default:
$ref: ../components/responses.yml#/Problem