labthings / labthings/labthings-fastapi

Consistent handling of affordance `title` fields

Open
#218 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Currently, we try to use the first line of a docstring as the title of Action and Property affordances. This is used both in the OpenAPI document and the Thing Description. By convention, the first line of a docstring is a summary of the function or property.

While reviewing #215 @julianstirling pointed out this is a slightly confusing way to do things. I have also entertained the idea that it might be neater simply to title-case the name of each affordance to generate the title by default. This would result in rather shorter titles, which is probably in line with what's usually expected.

Currently, the title is used in the Thing Description and OpenAPI documents, the OpenAPI document titles then appear in the SwaggerUI interface. I don't believe either is particularly prominent in the UI of the OpenFlexure Microscope, but in theory one might expect that title would be a reasonable string to put on a button for an action, or to use as a label for a property. I think in both these cases, a title-cased version of name is probably preferable.

We could and should provide a way to set an explicit title (or indeed multilingual titles) in the future, but that's probably not a task for the short term.

I think I have talked myself round to suggesting that name should be turned into title rather than pulling it out of __doc__, but I'm open to other opinions, up to and including the suggestion that we keep the status quo.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the code that builds Action and Property affordances and emits their OpenAPI and Thing Description representations. Compare the current docstring-derived titles with the proposed name-derived behavior, then confirm the chosen default and verify both generated documents and any existing tests reflect it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.