Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/foxcapades/lib-go-raml

Type definitions & utilities for working with RAML in Go
https://github.com/foxcapades/lib-go-raml

golang golang-library raml

Last synced: 5 days ago
JSON representation

Type definitions & utilities for working with RAML in Go

Awesome Lists containing this project

README

        

= RAML <--> Go

Parser & serializer for https://raml.org/[RAML] documents to/from concrete Go
types.

.cmd/example/main.go
[source, go]
----
func main() {
res, err := simple.GetRequest("https://raw.githubusercontent.com/raml-org/raml-examples/master/annotations/advanced.raml").
Submit().
GetRawResponse()
check(err)
defer res.Body.Close()

api, err := rparse.ParseApiDoc(res.Body)
check(err)

check(api.WriteRAML(os.Stdout))
}

func check(err error) {
if err != nil {
panic(err)
}
}
----

.example output
[source, sh-session]
----
$ go run v0/cmd/example/main.go
#%RAML 1.0
---
title: Illustrating annotations
mediaType:
- application/json
annotationTypes:
deprecated: nil
experimental: string | nil
feedbackRequested: string?
testHarness:
type: string # This line may be omitted as it's the default type
badge:
clearanceLevel:
properties:
level:
enum: [low, medium, high]
required: true
signature:
pattern: "\\d{3}-\\w{12}"
required: true
/groups:
(experimental):
(feedbackRequested):
/users:
(testHarness): usersTest
(badge): tested.gif
(clearanceLevel):
level: high
signature: 230-ghtwvfrs1itr
get:
(deprecated):
(experimental):
(feedbackRequested): Feedback committed!
responses:
200:
----