lib-go-raml

module
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2023 License: MIT

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:
----

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL