DSL for defining SCIM schemas declaratively.
This module provides macros for building RFC 7643-compliant SCIM schema definitions in a clean, readable format.
Example
defmodule MyApp.Schemas.User do
use ExScim.Schema.Builder
schema "urn:ietf:params:scim:schemas:core:2.0:User" do
name "User"
description "User Account"
attribute :userName, :string, required: true, uniqueness: :server
attribute :active, :boolean
attribute :name, :complex do
sub_attribute :givenName, :string
sub_attribute :familyName, :string
end
attribute :emails, :complex, multi_valued: true do
sub_attribute :value, :string
sub_attribute :type, :string, canonical_values: ["work", "home", "other"]
sub_attribute :primary, :boolean
end
end
endGenerated Functions
Using this module generates the following functions:
schema_id/0- Returns the schema URIto_map/0- Returns the complete schema as a map__schema__/0- Returns schema metadata (for internal use)
Summary
Functions
Defines a simple attribute with name and type.
Defines an attribute with options, or a complex attribute with sub-attributes.
Defines a complex attribute with both options and sub-attributes.
Sets the description for the schema.
Sets the human-readable name for the schema.
Defines a SCIM schema with the given URI identifier.
Defines a sub-attribute within a complex attribute block.
Functions
Defines a simple attribute with name and type.
Example
attribute :active, :boolean
Defines an attribute with options, or a complex attribute with sub-attributes.
Simple attribute with options
attribute :userName, :string, required: true, uniqueness: :serverComplex attribute with sub-attributes
attribute :name, :complex do
sub_attribute :givenName, :string
sub_attribute :familyName, :string
endOptions
:required- boolean, defaultfalse:multi_valued- boolean, defaultfalse:case_exact- boolean, defaultfalse(only for string/reference types):mutability- atom, one of:read_write,:read_only,:write_only,:immutable:returned- atom, one of:default,:always,:never,:request:uniqueness- atom, one of:none,:server,:global:canonical_values- list of strings:reference_types- list of strings (only for reference type):description- string
Defines a complex attribute with both options and sub-attributes.
Example
attribute :emails, :complex, multi_valued: true do
sub_attribute :value, :string
sub_attribute :type, :string, canonical_values: ["work", "home", "other"]
sub_attribute :primary, :boolean
end
Sets the description for the schema.
Sets the human-readable name for the schema.
Defines a SCIM schema with the given URI identifier.
The block should contain name/1, description/1, and attribute calls.
Example
schema "urn:ietf:params:scim:schemas:core:2.0:User" do
name "User"
description "User Account"
# attributes...
end
Defines a sub-attribute within a complex attribute block.
Must be called inside an attribute ... do ... end block.
Example
attribute :name, :complex do
sub_attribute :givenName, :string
sub_attribute :familyName, :string, description: "The family name"
endOptions
Same options as attribute/3, with the addition of :include_uniqueness
which forces uniqueness to be included even for boolean types.