Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples to Swagger for Senses in gloss update #1462

Open
susanodd opened this issue Jan 20, 2025 · 6 comments
Open

Add examples to Swagger for Senses in gloss update #1462

susanodd opened this issue Jan 20, 2025 · 6 comments

Comments

@susanodd
Copy link
Collaborator

susanodd commented Jan 20, 2025

BRING BACK THE EXAMPLES from the lost Wiki API examples page

This is incorrect and confusing.

This is what should be the right-hand-side of the json data for Senses:

{"en":[["sense 1 keyword1", "sense 1 keyword2"],["sense 2 keyword1"]], "nl":[["sense 1 keyword1"],["sense 2 keyword1", "sense 2 keyword2"]]}

@susanodd
Copy link
Collaborator Author

@vanlummelhuizen the json expression shown above is from @Jetske. It's the help text if there is an error on the Senses input. Observe that it is not a string.

The original API code was originally a copy paste from the normal interface for senses.

@vanlummelhuizen
Copy link
Collaborator

Do you mean

return {}, "Sense input is not in the expected format. \nTry: '{\"en\":[[\"sense 1 keyword1\", \"sense 1 keyword2\"],[\"sense 2 keyword1\"]], \"nl\":[[\"sense 1 keyword1\"],[\"sense 2 keyword1\", \"sense 2 keyword2\"]]}'"
?

I get that this should be correct and therefore helpful to the user, but unfortunately it isn't. The JSON you mention above is in single quotes in the help string, so it could be interpreted both as a JSON and as string, making it ambiguous indeed.

```python >>> print("Sense input is not in the expected format. \nTry: '{\"en\":[[\"sense 1 keyword1\", \"sense 1 keyword2\"],[\"sense 2 keyword1\"]], \"nl\":[[\"sense 1 keyword1\"],[\"sense 2 keyword1\", \"sense 2 keyword2\"]]}'") Sense input is not in the expected format. Try: '{"en":[["sense 1 keyword1", "sense 1 keyword2"],["sense 2 keyword1"]], "nl":[["sense 1 keyword1"],["sense 2 keyword1", "sense 2 keyword2"]]}' ```

So, there are two solution to this issue and #1460 :

@susanodd
Copy link
Collaborator Author

It was always a json structure. The "update" takes a HUGE json structure containing all the gloss fields that are to be updated.

There used to be numerous examples of how to use it. Both input json and output json.

That was in a separate Wiki API examples page. That page disappeared. Now only Swagger is left.
But Swagger does not have sufficient examples of how to use it.

It was never just a string. It was always a json structure.

We used to use JSON.stringify before passing the giant "update dictionary" in the API.

I don't know about Swagger. It's like it has forms internal to it.

@susanodd
Copy link
Collaborator Author

The "relatively easy" does not work. See the log messages in comments. It causes constraint violations. (This has to do with objects inside the query being deleted while they are still being used. I debugged the original code line by line and there kept being errors. Moreover, it only works to delete the Translation objects if their ids are collected, then they are retrieved and deleted. See the pull request code. Otherwise Django just ignores the attempts to delete. Probably because it's inside a relation table between Gloss and Translation.)

I already implemented the "more work" solution.

@susanodd
Copy link
Collaborator Author

The JSON is in a single quotes because that's how you normally write 'def gloss_update(' code examples. So the reader does not think it's English.

@susanodd
Copy link
Collaborator Author

The intention of this issue is to BRING BACK THE EXAMPLES

Not to discuss gloss update.

@susanodd susanodd changed the title Fix the Swagger description of Senses for gloss update Add examples to Swagger for Senses in gloss update Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants