EVE-KILL / Issues

Issues and Feature requests go here
MIT License
0 stars 0 forks source link

API returns Int type for name for this character: https://eve-kill.com/character/90003455 #29

Closed OrangeDrangon closed 1 month ago

OrangeDrangon commented 1 month ago

Describe the bug If you query the id 90003455 from the character api the name field is an int instead of string.

To Reproduce Steps to reproduce the behavior: Any API request will do: image

Expected behavior Stringify the value.

Additional context Occurs on the post endpoint and the get endpoint. Probably stored in the backend database that way if I had to guess.

karbowiak commented 1 month ago

Ah yeah, i see - that's because of the fact the character is a deleted character, so i can't update the data for it.

The name IS the numbers tho, so if you can handle casting it to a string then it should be accurate :)

OrangeDrangon commented 1 month ago

I would assume for consistency the api would return "NUM" instead of NUM. But it can definitely be handled on the client end if you do not want to mess with it.

karbowiak commented 1 month ago

Problem is it's correct in my DB, it's when i use the $this->json(..) output in the controller that it happens 😅

image

So if you can just assume name is always a string on your end, that'd solve the problem, otherwise i gotta revamp my json encoder class to solve it

OrangeDrangon commented 1 month ago

The problem is https://www.php.net/manual/en/json.constants.php#constant.json-numeric-check set in https://github.com/EVE-KILL/Killboard/blob/b98a51f7c5557c8d265ec33eff9961cc55d78fee/src/Api/Abstracts/Controller.php#L303C37-L303C48

When you read it out of the database it is a string but when you serialize it it gets auto converted to an int. I assume this is because you have other data that needs the flag in the database?

karbowiak commented 1 month ago

You're right, lets try and remove that and see what it does 😂

karbowiak commented 1 month ago

https://eve-kill.com/api/characters/90003455

Looks correct now - neato, and nothing seems to be broken either