JSON Schemaでバックエンドエンジニアとフロントエンドエンジニアがコラボする / json-schema-collaboration

5919537a0ecfa5d4dea704cf878ae90e?s=47 toshimaru
December 08, 2015

JSON Schemaでバックエンドエンジニアとフロントエンドエンジニアがコラボする / json-schema-collaboration

『エムスリー x Gunosy Beer bash』( http://gunosy-beer.connpass.com/event/22825/ ) での発表スライドです。

- 内容をまとめたBlog記事はこちら: http://blog.toshimaru.net/json-schema-collaboration/

5919537a0ecfa5d4dea704cf878ae90e?s=128

toshimaru

December 08, 2015
Tweet

Transcript

  1. 2.

    Self Introduction » @toshimaru_e » Rails Developer @Gunosy » Gunosy

    Web (gunosy.com) » ! RailsΤϯδχΞืूத !
  2. 11.

    ίϥϘਤ +------------------+ | | | Client-side JS | | (React)

    | | | +---+--------+-----+ | ^ | | +---------------+ | JSON | <-------- | JSON Schema | | | +---------------+ v | +---+--------+-----+ | | | Server-side API | | (Rails) | | | +------------------+
  3. 12.

    JSON Schema for us » For Humans » Clear specification

    » For Apps » useful for Validation » useful for Test » etc.
  4. 18.

    # user.schema.yml $schema: http://json-schema.org/draft-04/schema# title: User description: An User type:

    object properties: id: type: integer email: type: string format: email name: type: string minLength: 1 maxLength: 32 required: - id - email - name
  5. 19.
  6. 20.

    JSON Schema Validation require 'json-schema' schema = { "type" =>

    "object", "required" => ["a"], "properties" => { "a" => {"type" => "integer"} } } data = { "a" => 5 } JSON::Validator.validate(schema, data)
  7. 21.

    RSpec JSON Schema Matcher 1 describe "Fetching the current user"

    do context "with valid auth token" do it "returns the current user" do user = create(:user) auth_header = { "Auth-Token" => user.auth_token } get v1_current_user_url, {}, auth_header expect(response.status).to eq 200 expect(response).to match_response_schema("user") end end end 1 Validating JSON Schemas with an RSpec Matcher
  8. 24.

    json-schema vs json_schema » depending on json_schema: » interagent/committee »

    interagent/prmd » increments/qiita-rb » r7kamura/rack-json_schema » r7kamura/jdoc
  9. 29.

    JSON Schemaͷ ࠓͱ͜Ε͔Β » JSON Schema v5 Proposals͕ ग़͞Ε͍ͯΔஈ֊ »

    Issue΍Google GroupsΛ௥͏ͱ Α͛͞ » v5΁ͷ۩ମతͳϩʔυϚοϓ͸Ҿ͔ Ε͍ͯͳ͍໛༷