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

SOLR-17062: Create JS client for Admin UI use #2050

Merged
merged 9 commits into from
Nov 13, 2023
17 changes: 17 additions & 0 deletions solr/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

plugins {
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.2'
id "org.openapi.generator" version "6.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I looked and there is a 7.0.1 versin https://plugins.gradle.org/plugin/org.openapi.generator, maybe we have to update gradle?

}

apply plugin: 'java-library'
Expand Down Expand Up @@ -55,8 +56,24 @@ dependencies {
testImplementation 'org.apache.lucene:lucene-test-framework'
}

// Ensure the OAS is available to other modules who want to generate code (i.e. solrj)
artifacts {
openapiSpec resolve.outputDir, {
builtBy resolve
}
}

// Non-Java client generation tasks below:

task buildJSClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
generatorName.set("javascript-closure-angular")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gerlowskija a few thoughts:

  1. I strongly recommend to use the typescript or javascript generators rather than one that ties users to a specific vendor. Specifically, AngularJS is a deprecated project and the version Solr was built on doesn't even exist anymore. The Angular that sort of lives on is written in Typescript.

  2. The typescript option is listed in the docs as experimental, though I doubt it would be very experimental and typescript-node is labeled stable. In reality, both are probably more stable than thejavascript option. The javascript option may offer a slightly lower barrier to entry for future contributors for now, while the typescript one will have a growing ecosystem and offer far better maintainability in the future.

  3. The biggest benefits of the Typescript language are maintenance and developer experience, especially for a team of Java users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we want to dog-food our current Admin UI first, perhaps the pure javascript client fits best. But for sure, once we plan to release something for customer use, TS bindings would likely be requested. Do we know whether the "typescript" generator is identical to the javascript generator plus types, or are they separate templates?

Copy link
Contributor Author

@gerlowskija gerlowskija Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly recommend to use the typescript or javascript generators

👍 - I chose 'javascript-closure-angular' somewhat arbitrarily. I knew in a vague sense that the Admin UI used Angular, and just went with that. But I like your point about vendor-neutrality. Will update this to use the 'javascript' generator.

(I was under the impression that typescript was a distinct language from Javascript, and that the two weren't necessarily interchangeable. But I'm getting the sense from you guys above that there's more interplay there than I'd imagined. I've got some reading to do I think...)

Do we know whether the "typescript" generator is identical to the javascript generator plus types, or are they separate templates?

I don't know, but it's something I can check on. The default templates for each generator are in subdirectories here, so we'd just need to find the two relevant dirs and diff them.

inputSpec.set("$openApiSpecFile")
outputDir.set("${buildDir}/generated/js")
packageName.set("solr")
generateApiTests.set(false)
generateModelTests.set(false)
}

tasks.withType(org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
dependsOn(resolve)
}
Loading