Хотя проблема кажется простой, но я не могу получить ответ OK 200 при попытке зарегистрировать экземпляр.
def register(InstanceString: String) : server.Route = {
post
{
log.debug(s"POST /register has been called, parameter is: $InstanceString")
try {
val paramInstance : Instance = InstanceString.parseJson.convertTo[Instance](instanceFormat)
handler.handleRegister(paramInstance) match {
case Success(id) =>
complete{id.toString}
}}}
Выше приведен метод, выполняющий запрос.
Ниже приведена его конфигурация API:
paths:
/register:
post:
tags:
- Basic Operations
summary: Register a new instance at the registry
operationId: addInstance
parameters:
- in: body
name: InstanceToRegister
required: true
schema:
$ref: '#/definitions/Instance'
responses:
'200':
description: The ID of the registered instance
schema:
type: integer
format: int64
example: 42
Ниже приведен тестовый пример, который я пытаюсь выполнить, но получаю 400 Bad Request, не равное 200 OK.
"The Server" should {
"Successfully Register" in {
Post("/register", HttpEntity(ContentTypes.`application/json`,"""{"InstanceString":"hallo"}""")) ~> Route.seal(routes) ~> check {
assert(status === StatusCodes.OK)