-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: Generate client API code, part 1 #1259
Conversation
…tion of client code.
* test: Compare instances with class definitions (ongoing). * test: Check responses against ontology defs (ongoing). * test: Check instance against ontology (ongoing). * feat: Check Knora responses against ontologies (ongoing). * test: Check Knora responses against ontology definitions (ongoing). * test: Check Knora responses against ontologies (ongoing). * test: Import some functionality from #1259. * test: Import functionality from #1259. * test: Check Knora responses against ontologies (ongoing). - Fix some inconsistencies in ontologies. * test: Check Knora responses against ontologies (ongoing). - Fix more inconsistencies in ontologies. * chore(api-v2): Fix Gravesearch type inference not to infer knora-api:ValueBase types. * style (InstanceChecker): Clarify code, add comments. * test: Start adding InstanceCheckerSpec. * fix(api-v2): Put hasStandoffLinkTo back in simple schema because Gravsearch needs it. - Fix broken IT test. * test(InstanceChecker): Test InstanceChecker (ongoing). * test(InstanceChecker): Test InstanceChecker (ongoing). * test(InstanceChecker): Test InstanceChecker (ongoing). * test(InstanceChecker): Test InstanceChecker with JSON.
# Conflicts: # webapi/src/main/scala/org/knora/webapi/messages/v2/responder/ontologymessages/OntologyMessagesV2.scala
- Generate URL query parameters. - Fix empty URL paths. - Support type conversion in function calls. - Support integer literals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Thanks :-)
Thanks, glad you like it! |
This pull request has been mentioned on Discuss DaSCH. There might be relevant details there: https://discuss.dasch.swiss/t/generating-client-libraries/25/2 |
This pull request has been mentioned on Discuss DaSCH. There might be relevant details there: https://discuss.dasch.swiss/t/generating-client-libraries/25/3 |
code for the specified target: | ||
|
||
``` | ||
HTTP GET to http://host/v2/clientapi/TARGET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2
should be removed from the path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will fix in a new PR when I get back from holiday.
I have looked into the TypeScript source and found the following issues: Classes
Types
As a general remark, if we really auto-generate everything, then we do not need to create the interfaces. I think it looks good so far. I could not compile the library yet due to these issues, but I suppose it would be possible to fix them. |
As answer to your question: We do not need the interfaces/base classes until we bump into circular references. Indeed, I have found circular imports already which will lead to compile errors. For example, the class |
@andreas-aeschlimann Thanks for checking the generated code.
Are you talking about the directory structure or the filenames? I tried to keep the same directory structure, but some of the filenames are different. I assumed that the filenames were not important, but if you like the old filenames better, we can change them.
Can you be more specific about which ones are incorrect and what they should be?
It can be difficult to control whitespace in the output while still keeping the templates readable. I will try.
I don't understand. Where should the space be? Can you give an example?
That's easy to add.
OK, that makes things simpler. :) Since this PR has already been merged, please open a new issue for what needs to be changed. I can look at it when I get back from holiday on 12 August. Or you can try changing the TypeScript backend code and templates yourself: https://github.com/dhlab-basel/Knora/tree/develop/webapi/src/main/twirl/clientapi/typescript |
Can you make a list of which classes need interfaces? |
I will be back mid August as well, so I will gladly respond you in detail then. Have a great time! |
This PR is a first step towards #1256.
ClientApi
, a programming-language-independent representation of a Knora client API. EachKnoraRoute
can implementClientEndpoint
to define client API functions that should be generated./clientapi/TARGET
, that generates client API code for the specified programming language target, returning a Zip file.GeneratorFrontEnd
, which converts ontology class definitions into instances ofClientClassDefinition
, which are suitable for use in code generation.docs/src/paradox/05-internals/design/client-api/index.md
).GeneratorBackEnd
.typescript
inTypeScriptBackEnd
, which generates source code for use with knora-api-js-lib, using templates intwirl/clientapi/typescript
.AdminClientApi
, defining the admin client API. Implemented so far:UsersRouteADM
PermissionsRouteADM
GroupsRouteADM
ProjectsRouteADM
To test locally, start Knora and visit http://0.0.0.0:3333/clientapi/typescript.
To do in subsequent PRs: