This commit is contained in:
2026-01-01 15:49:49 +01:00
parent 8c289622e1
commit 85567d87b7
8 changed files with 29 additions and 26 deletions

View File

@@ -19,16 +19,16 @@ import json
from typing import Optional from typing import Optional
from pydantic import BaseModel, StrictStr from pydantic import BaseModel, Field, StrictStr
class ClientDto(BaseModel): class ClientDto(BaseModel):
""" """
ClientDto ClientDto
""" """
name: Optional[StrictStr] = None company_name: Optional[StrictStr] = Field(None, alias="companyName")
username: Optional[StrictStr] = None username: Optional[StrictStr] = None
key: Optional[StrictStr] = None key: Optional[StrictStr] = None
__properties = ["name", "username", "key"] __properties = ["companyName", "username", "key"]
class Config: class Config:
"""Pydantic configuration""" """Pydantic configuration"""
@@ -66,7 +66,7 @@ class ClientDto(BaseModel):
return ClientDto.parse_obj(obj) return ClientDto.parse_obj(obj)
_obj = ClientDto.parse_obj({ _obj = ClientDto.parse_obj({
"name": obj.get("name"), "company_name": obj.get("companyName"),
"username": obj.get("username"), "username": obj.get("username"),
"key": obj.get("key") "key": obj.get("key")
}) })

View File

@@ -4,7 +4,7 @@
## Properties ## Properties
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional] **company_name** | **str** | | [optional]
**username** | **str** | | [optional] **username** | **str** | | [optional]
**key** | **str** | | [optional] **key** | **str** | | [optional]

View File

@@ -36,7 +36,7 @@ class TestClientDto(unittest.TestCase):
model = ClientDto() # noqa: E501 model = ClientDto() # noqa: E501
if include_optional: if include_optional:
return ClientDto( return ClientDto(
name = '', company_name = '',
username = '', username = '',
key = '' key = ''
) )

View File

@@ -44,7 +44,7 @@ components:
ClientDto: ClientDto:
type: "object" type: "object"
properties: properties:
name: companyName:
type: "string" type: "string"
nullable: true nullable: true
username: username:

View File

@@ -19,6 +19,7 @@ class AuthController:
auth_api = AuthApi(client) auth_api = AuthApi(client)
auth_request = AuthRequestDto( auth_request = AuthRequestDto(
username=StrictStr(received_data["username"]),
username=StrictStr(received_data["username"]), username=StrictStr(received_data["username"]),
key=StrictStr(received_data["key"]), key=StrictStr(received_data["key"]),
) )

View File

@@ -1,5 +1,5 @@
from board_mate.client import Configuration, ApiClient, ClientApi, ClientDto, ApiException from board_mate.client import Configuration, ApiClient, ClientApi, ClientDto, ApiException
from flask import jsonify from flask import jsonify, request
from pydantic import StrictStr from pydantic import StrictStr
@@ -13,20 +13,24 @@ class GameController:
app.add_url_rule("/client/create", view_func=self.create, methods=['POST']) app.add_url_rule("/client/create", view_func=self.create, methods=['POST'])
def create(self): def create(self):
try:
with ApiClient(self.config) as api_client: with ApiClient(self.config) as api_client:
request_data = request.get_json()
client_api = ClientApi(api_client) client_api = ClientApi(api_client)
new_client = ClientDto( new_client = ClientDto(
name=StrictStr("Alice Example"), companyName=StrictStr(request_data["companyName"]),
username=StrictStr("alice123"), username=StrictStr(request_data["username"]),
key=StrictStr(request_data["key"]),
) )
try:
response = client_api.create(client_dto=new_client) response = client_api.create(client_dto=new_client)
print("Success:", response.success) print("Success:", response.success)
print("Message:", response.message) print("Message:", response.message)
print("Data:", response.data) print("Data:", response.data)
return jsonify(response), 200 return jsonify(response), 200
except ApiException as e: except ApiException as e:
print(f"Exception when calling ClientApi->create: {e}") print(f"Exception when calling ClientApi->create: {e}")
return jsonify(response), 500 return jsonify(response), 500

View File

@@ -1,7 +1,5 @@
package be.naaturel.boardmateapi.controllers; package be.naaturel.boardmateapi.controllers;
import be.naaturel.boardmateapi.controllers.dtos.AuthRequestDto;
import be.naaturel.boardmateapi.controllers.dtos.AuthResponseDto;
import be.naaturel.boardmateapi.controllers.dtos.ClientDto; import be.naaturel.boardmateapi.controllers.dtos.ClientDto;
import be.naaturel.boardmateapi.controllers.dtos.ResponseBody; import be.naaturel.boardmateapi.controllers.dtos.ResponseBody;
import be.naaturel.boardmateapi.services.ClientService; import be.naaturel.boardmateapi.services.ClientService;
@@ -27,7 +25,7 @@ public class ClientController {
public ResponseEntity<ResponseBody<String>> create(@RequestBody ClientDto dto) { public ResponseEntity<ResponseBody<String>> create(@RequestBody ClientDto dto) {
ResponseBody<String> result = ResponseBody.createEmpty(); ResponseBody<String> result = ResponseBody.createEmpty();
try{ try{
String clientId = service.create(dto.getName(), dto.getUsername(), dto.getKey()); String clientId = service.create(dto.getCompanyName(), dto.getUsername(), dto.getKey());
result.setData(clientId); result.setData(clientId);
return ResponseEntity. return ResponseEntity.
status(HttpStatus.OK) status(HttpStatus.OK)

View File

@@ -2,16 +2,16 @@ package be.naaturel.boardmateapi.controllers.dtos;
public class ClientDto { public class ClientDto {
private String name; private String companyName;
private String username; private String username;
private String key; private String key;
public String getName() { public String getCompanyName() {
return name; return companyName;
} }
public void setName(String name) { public void setCompanyName(String companyName) {
this.name = name; this.companyName = companyName;
} }
public String getUsername() { public String getUsername() {