|
| 1 | +:req-class: profile-codelists |
| 2 | +[#rc_{req-class}] |
| 3 | +== Requirements Class "Profiles for codelists" |
| 4 | + |
| 5 | +The Requirements Class "Profiles for codelists" specifies two profiles for representing enumerated values with additional information about each value, typically including a human-readable label (codelists). Enumerated values without additional information about each value are specified in the "enum" member of the JSON Schema. |
| 6 | + |
| 7 | +It is good practice to publish codelists as resources on the web - as HTML, SKOS, a JSON object with each code value as a key, and/or another format. |
| 8 | + |
| 9 | +When requesting a schema that contains properties with values from a codelist, the response should not only list the codes, but also provide access to additional information about each code. |
| 10 | + |
| 11 | +Two different representations of a property with values from a codelist are specified as profiles. |
| 12 | + |
| 13 | +The first profile ("codelist-inline") uses "oneOf" with a schema for each code. This profile has the advantage that all information is in the schema; no external information needs to be accessed. |
| 14 | + |
| 15 | +The second profile ("codelist-ref") uses "enum" with a URI reference to the codelist resource. This has the advantage that "enum" is easier to parse/handle than "oneOf" and that a separate resource for codelists may be useful for other purposes, too, and in fact may already be published. |
| 16 | + |
| 17 | +[cols="2,7",width="90%"] |
| 18 | +|=== |
| 19 | +^|*Requirements Class* |http://www.opengis.net/spec/{standard}/{m_n}/req/{req-class} |
| 20 | +|Target type |Web resources |
| 21 | +|Dependency |<<rc_schemas>> |
| 22 | +|Dependency |<<rc_profile-parameter>> |
| 23 | +|=== |
| 24 | + |
| 25 | +:req: ref-profiles |
| 26 | +[#{req-class}_{req}] |
| 27 | +[width="90%",cols="2,7a"] |
| 28 | +|=== |
| 29 | +^|*Requirement {counter:req-num}* |/req/{req-class}/{req} |
| 30 | +^|A |Any schema resource SHALL provide the query parameter "profile". |
| 31 | +|=== |
| 32 | +
|
| 33 | +:req: codelist-inline |
| 34 | +[#{req-class}_{req}] |
| 35 | +[width="90%",cols="2,7a"] |
| 36 | +|=== |
| 37 | +^|*Requirement {counter:req-num}* |/req/{req-class}/{req} |
| 38 | +^|A |In the profile "codelist-inline" (`\http://www.opengis.net/def/profile/OGC/0/codelist-inline`) the schema of each property with values from a codelist SHALL be represented by a "oneOf" schema with a schema for each code. |
| 39 | +^|B |The schema for each code SHALL have a "const" member with the code as the value. |
| 40 | +|=== |
| 41 | + |
| 42 | +:rec: codelist-inline-title |
| 43 | +[#{req-class}_{rec}] |
| 44 | +[width="90%",cols="2,7a"] |
| 45 | +|=== |
| 46 | +^|*Recommendation {counter:rec-num}* |/req/{req-class}/{rec} |
| 47 | +^|A |In the profile "codelist-inline", the schema for each code SHOULD have a "title" member. |
| 48 | +|=== |
| 49 | +
|
| 50 | +[[example_15_1]] |
| 51 | +.Profile "codelist-inline" |
| 52 | +==== |
| 53 | +[source,JSON] |
| 54 | +---- |
| 55 | +{ |
| 56 | + "title": "Language", |
| 57 | + "oneOf": [ |
| 58 | + { |
| 59 | + "const": "eng", |
| 60 | + "title": "English" |
| 61 | + }, |
| 62 | + { |
| 63 | + "const": "deu", |
| 64 | + "title": "German" |
| 65 | + }, |
| 66 | + { |
| 67 | + "const": "fra", |
| 68 | + "title": "French" |
| 69 | + }, |
| 70 | + { |
| 71 | + "const": "spa", |
| 72 | + "title": "Spanish" |
| 73 | + } |
| 74 | + ] |
| 75 | +} |
| 76 | +---- |
| 77 | +==== |
| 78 | +
|
| 79 | +:req: codelist-ref |
| 80 | +[#{req-class}_{req}] |
| 81 | +[width="90%",cols="2,7a"] |
| 82 | +|=== |
| 83 | +^|*Requirement {counter:req-num}* |/req/{req-class}/{req} |
| 84 | +^|A |In the profile "codelist-ref" (`\http://www.opengis.net/def/profile/OGC/0/codelist-ref`) the codelist SHALL be referenced by a HTTP(S) URI using the keyword "x-ogc-codelistUri". |
| 85 | +|=== |
| 86 | + |
| 87 | +[[example_15_2]] |
| 88 | +.Profile "codelist-ref" |
| 89 | +==== |
| 90 | +[source,JSON] |
| 91 | +---- |
| 92 | +{ |
| 93 | + "title": "Language", |
| 94 | + "type": "string", |
| 95 | + "enum": [ |
| 96 | + "eng", |
| 97 | + "deu", |
| 98 | + "fra", |
| 99 | + "spa" |
| 100 | + ], |
| 101 | + "x-ogc-codelistUri": "https://example.com/codelists/languages" |
| 102 | +} |
| 103 | +---- |
| 104 | +==== |
| 105 | + |
| 106 | +:per: default |
| 107 | +[#{req-class}_{per}] |
| 108 | +[width="90%",cols="2,7a"] |
| 109 | +|=== |
| 110 | +^|*Permission {counter:per-num}* |/rec/{req-class}/{per} |
| 111 | +^|A |A resource MAY support only one of the profiles. |
| 112 | +^|B |Any codelist profile MAY be the default profile for a schema resource. |
| 113 | +|=== |
0 commit comments