Coder Social home page Coder Social logo

Comments (2)

andygrunwald avatar andygrunwald commented on June 3, 2024

I had a quick chat with @phiesel about this topic.
Patrick was mentioned in the ESC minutes to be the person to look at the topic.
He said (quote):

we won't move to Swagger etc. any time soon because it fails the const/benefit tradeoff. Gerrit as you might know allows plugins to also expose REST APIs and it's not trivial to support this in exactly the same way with Swagger.

We will likely move our entity definitions to Protobuf so that callers can reuse the object definitions. All that's left to do then is use a proto2json mapper (those are widely available) and call the URLs. Surely, service definitions would be way nice than calling URLs with an HTTP framework, but it's hard to make the Gerrit server work with Swagger, etc.

[...]

Proto files will be open-source, so you can compile them into your binary in your language of choice.

What does this mean for us + this project right now?

I suggest we document the current status in the README + that we keep an eye on future Gerrit versions to add support for Protobuf.

from go-gerrit.

andygrunwald avatar andygrunwald commented on June 3, 2024

A quick/dirty idea:

Gerrits documentation is written in asciidoc: https://gerrit.googlesource.com/gerrit/+/refs/heads/master/Documentation/
The endpoints and content types are (more or less)unified.

Similar to go-github (https://github.com/google/go-github/blob/master/github/gen-accessors.go), we can create a go generate script that

  • Checks if we have implemented all endpoints
  • Verified we have all fields inside the Content-type structs

It won't be a good generate script, but more a "there is something missing" script.
Additionally, the documentation don't cover the types of the struct members.

github.com/bytesparadise/libasciidoc could be a library to parse the asciidoc on this.

Maybe the whole thing is a bit over-engineered.
However, it would keep us up to date with changes in gerrit as well (as long as they are documented in asciidoc).

Just posting this piece of code here for the future me to not start 100% from scratch:

package main

import (
	"fmt"
	"os"

	"github.com/bytesparadise/libasciidoc/pkg/configuration"
	"github.com/bytesparadise/libasciidoc/pkg/parser"
	"github.com/bytesparadise/libasciidoc/pkg/types"
)

func main() {
	filePath := "/Users/agrunwald/Development/gerrit/Documentation/rest-api-groups.txt"

	file, err := os.Open(filePath)
	if err != nil {
		panic(err)
	}
	defer file.Close()

	config := configuration.Configuration{}
	doc, err := parser.ParseDocument(file, config)
	if err != nil {
		panic(err)
	}

	for _, v := range doc.Elements {
		t := v.(types.Section)

		for _, sect := range t.Title {
			fmt.Print("%+v", sect)
		}
	}
}

from go-gerrit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.