unrelentingtech / Octohipster
Licence: unlicense
[UNMAINTAINED] A hypermedia REST HTTP API library for Clojure
Stars: ✭ 77
Programming Languages
clojure
4091 projects
Labels
Projects that are alternatives of or similar to Octohipster
Skeleton
🔨 Nepxion Skeleton is a generic codes and files generator based on freemaker for any text formats, and provides skeleton of Spring Cloud with docker deployment 基于Docker & Spring Cloud的代码和文件的脚手架生成平台
Stars: ✭ 61 (-20.78%)
Mutual labels: swagger
Bee
Bee is a tool for helping develop with beego app framework.
Stars: ✭ 1,165 (+1412.99%)
Mutual labels: swagger
Spring Boot Webflux Swagger Starter
An example project to illustrate how to document Spring Boot Webflux with Swagger2
Stars: ✭ 62 (-19.48%)
Mutual labels: swagger
Restfeel
RESTFeel: 一个企业级的API管理&测试平台。RESTFeel帮助你设计、开发、测试您的API。
Stars: ✭ 59 (-23.38%)
Mutual labels: swagger
Swagger ui engine
Include swagger-ui as rails engine and document your API with simple JSON or YAML files.
Stars: ✭ 77 (+0%)
Mutual labels: swagger
Eshop Soa
EShop基于Dubbo实现SOA服务化拆分,并基于RocketMQ解决了分布式事务(新版SpringBootSOASkeleton)
Stars: ✭ 65 (-15.58%)
Mutual labels: swagger
X Springboot
X-SpringBoot是一个轻量级的Java快速开发平台,能快速开发项目并交付【接私活利器】
Stars: ✭ 1,117 (+1350.65%)
Mutual labels: swagger
Springwolf Core
Automated documentation for async APIs built with Spring Boot
Stars: ✭ 63 (-18.18%)
Mutual labels: swagger
Easy Mock
A persistent service that generates mock data quickly and provids visualization view.
Stars: ✭ 8,644 (+11125.97%)
Mutual labels: swagger
Openapi Mock Generator
Progressive Web App for generating mocked data from an OpenAPI specification
Stars: ✭ 72 (-6.49%)
Mutual labels: swagger
Azure Rest Api Specs
The source for REST API specifications for Microsoft Azure.
Stars: ✭ 1,104 (+1333.77%)
Mutual labels: swagger
Train Ai With Django Swagger Jwt
Train AI (Keras + Tensorflow) to defend apps with Django REST Framework + Celery + Swagger + JWT - deploys to Kubernetes and OpenShift Container Platform
Stars: ✭ 66 (-14.29%)
Mutual labels: swagger
Typerx
A lightweight typescript annotation rest based extra (express、 mongoose、 angular、zorro、ng-alain ...).
Stars: ✭ 76 (-1.3%)
Mutual labels: swagger
Openapi Spring Webflux Validator
🌱 A friendly kotlin library to validate API endpoints using an OpenApi 3.0 and Swagger 2.0 specification
Stars: ✭ 67 (-12.99%)
Mutual labels: swagger
Current semantic version:
[octohipster "0.2.1-SNAPSHOT"]
octohipster
Octohipster is
- a REST library/toolkit/microframework for Clojure
- that allows you to build HTTP APIs
- in a declarative Webmachine-like style, using Liberator
- powered by Ring; you can add rate limiting, authentication, metrics, URL rewriting and more with just middleware
It allows you to make APIs that
- support hypermedia (HAL+JSON, Collection+JSON and Link/Link-Template HTTP headers; works with Frenetic)
- support multiple output formats (JSON, EDN, YAML and any custom format)
- have Swagger documentation
- use JSON Schema for validation and documentation
- have pagination
Concepts
- a resource is a single endpoint that accepts requests and returns responses
- a group is a collection of resources with a single URL prefix (eg. a group /things contains resources /things/ and /things/{id}) and zero or more shared properties (usually the schema)
- a documenter is a function that returns a resource which documents regular resources (Swagger, HAL root, etc)
- a mixin is a function that is applied to multiple resources to give them shared behavior (eg. collection or entry behavior)
- a response handler is a function that is used to encode response data to a particular content-type (JSON, EDN, YAML, etc.)
- a params handler is a function that is used to decode incoming data from a particular content-type (JSON, EDN, YAML, etc.)
Usage
(ns example
(:use [octohipster core routes mixins pagination]
[octohipster.documenters swagger schema]
org.httpkit.server)
(:import org.bson.types.ObjectId)
(:require [monger.core :as mg]
[monger.query :as mq]
[monger.collection :as mc]
monger.json))
(mg/connect!)
(mg/set-db! (mg/get-db "octohipster-example"))
;;;; The "model"
;;;; tip: make it a separate namespace, eg. app.models.contact
(def contact-schema
{:id "Contact"
:type "object"
:properties {:name {:type "string"}
:phone {:type "integer"}}
:required [:name]})
(defn contacts-count [] (mc/count "contacts"))
(defn contacts-all []
(mq/with-collection "contacts"
(mq/find {})
(mq/skip *skip*)
(mq/limit *limit*)))
(defn contacts-find-by-id [x] (mc/find-map-by-id "contacts" (ObjectId. x)))
(defn contacts-insert! [x]
(let [id (ObjectId.)]
(mc/insert "contacts" (assoc x :_id id))
(mc/find-map-by-id "contacts" id)))
(defn contacts-update! [x old] (mc/update "contacts" old x :multi false))
(defn contacts-delete! [x] (mc/remove "contacts" x))
;;;; The resources
;; with shared pieces of documentation
(def name-param
{:name "name", :dataType "string", :paramType "path", :required "true", :description "The name of the contact", :allowMultiple false})
(def body-param
{:dataType "Contact", :paramType "body", :required true, :allowMultiple false})
(defresource contact-collection
:desc "Operations with multiple contacts"
:mixins [collection-resource]
:clinks {:item ::contact-item}
:data-key :contacts
:exists? (fn [ctx] {:contacts (contacts-all)})
:post! (fn [ctx] {:item (-> ctx :request :non-query-params contacts-insert!)})
:count (fn [req] (contacts-count))
:doc {:get {:nickname "getContacts", :summary "Get all contacts"}
:post {:nickname "createContact", :summary "Create a contact"}})
(defresource contact-item
:desc "Operations with individual contacts"
:url "/{_id}"
:mixins [item-resource]
:clinks {:collection ::contact-collection}
:data-key :contact
:exists? (fn [ctx]
(if-let [doc (-> ctx :request :route-params :_id contacts-find-by-id)]
{:contact doc}))
:put! (fn [ctx]
(-> ctx :request :non-query-params (contacts-update! (:contact ctx)))
{:contact (-> ctx :request :route-params :_id contacts-find-by-id)})
:delete! (fn [ctx]
(-> ctx :contact contacts-delete!)
{:contact nil})
:doc {:get {:nickname "getContact", :summary "Get a contact", :parameters [name-param]}
:put {:nickname "updateContact", :summary "Overwrite a contact", :parameters [name-param body-param]}
:delete {:nickname "deleteContact", :summary "Delete a contact", :parameters [name-param]}})
;;;; The group
(defgroup contact-group
:url "/contacts"
:add-to-resources {:schema contact-schema} ; instead of typing the same for all resources in the group
:resources [contact-collection contact-item])
;;;; The handler
(defroutes site
:groups [contact-group]
:documenters [schema-doc schema-root-doc swagger-doc swagger-root-doc])
(defn -main [] (run-server site {:port 8080}))
Also, API Documentation is available.
Contributing
By participating in this project you agree to follow the Contributor Code of Conduct.
Please take over the whole project!
I don't use Clojure a lot nowadays.
Talk to me: [email protected].
License
This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE
file or unlicense.org.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].