Donkie / Spoolman

Keep track of your inventory of 3D-printer filament spools.
MIT License
1k stars 93 forks source link

String behavior in (spool) extra fields #417

Closed CooperGerman closed 4 months ago

CooperGerman commented 4 months ago

Hi, Firstly thx again for the great work on this project it really helps out a lot for me ! I wanted to make sure that the way strings are treated when used in extra fields is correct.

I found out i had to escape them in order for the api to acept them :

async def add_extra_field(self, entity_type, field_name):
        '''
        Adds a new field to the extra field of the spoolman db
        '''
        response = await self.http_client.post(
            url=f'{self.spoolman_url}/v1/field/{entity_type}/{field_name}',
            body={"name" : field_name, "field_type" : "text", "default_value" : "\"N.A.\""}
        )

When added this way i see it like this in the broswer: image

and it does not appear in the spoolman webbrowser interface which hints me to think it might be a desired behavior. image

This is not a real problem since i can run with it but it might not be intended.

Thank you in advance for you answer

Donkie commented 4 months ago

Yes the value there needs to be json encoded, so in a python environment you would do something like: body={"name" : field_name, "field_type" : "text", "default_value" : json.dumps("N.A.")}

CooperGerman commented 4 months ago

Thank you very much, I thought so indeed.