JSON 스키마 기반 문서 (Documentation based on JSON Schema)


문제 설명

JSON 스키마 기반 문서 (Documentation based on JSON Schema)

제 JSON 스키마를 사용하여 문서를 생성하고 싶습니다.

아래 예에서는 JSON의 출력 메시지에서 사용할 수 있는 모든 ErrorNumber/ErrorMessage 조합을 나열하고 싶습니다.

하지만 개체 수준에서 방법을 찾을 수 없습니다. "예&" 또는 "열거형"; 실패했습니다.

해결 방법이 있습니까?

{
    "type": "object",
    "required": [
        "ErrorNumber",
        "ErrorMessage"
    ],
    "properties": {
        "ErrorNumber": {
            "$id": "#root/ErrorNumber", 
            "type": "integer"
        },
        "ErrorMessage": {
            "$id": "#root/ErrorMessage", 
            "type": "string"
        }
    }
}


참조 솔루션

방법 1:

  1. Did you mean to write "$ref" where you use "$id" in the example?

  2. Where exactly did you have problems with enum? The following works fine for me with a draft‑2020‑12 Validator (and after removing your "$id"!):


  3. </ol>

    {
      // ... your JSON here ...
      "enum": [
        {"ErrorNumber": 200, "ErrorMessage": "OK"},
        {"ErrorNumber": 404, "ErrorMessage": "Not found."}
        // ...
      ]
    }
    
    1. Different approaches, in case you still can change that:

    If your error numbers start at 0 and are contiguous, then an Array of messages might serve your purpose.

    Alternatively an object with numerical keys might:

    {
      "200": "OK",
      "404": "Not found."
    }
    

    (by TatouArthur_J)

    참조 문서

    1. Documentation based on JSON Schema (CC BY‑SA 2.5/3.0/4.0)

#Documentation #jsonschema #JSON






관련 질문

터미널에서 XCode docset 문서 보기 (View XCode docset docs from terminal)

ArrayList 생성자에 대한 JDK API 문서가 올바르지 않습니다. 버그인가요? (JDK API documentation is incorrect for ArrayList constructor. Is that a bug?)

스칼라의 변수 문서 (Variables documentation in Scala)

재정의된 메서드에 대한 신속한 문서 주석? (Swift documentation comments for overriden methods?)

이미 존재하는 doxygen 문서를 상호 참조하는 방법은 무엇입니까? (How to cross-reference already existing doxygen docs?)

Spring Mock mvc 호출에 객체 속성 전달 (Pass object attrbute to spring Mock mvc call)

docfx를 사용하여 참조 문서를 생성하는 방법 (How to generate documentation with references using docfx)

get_token_user_sub() 함수는 무엇을 해야 합니까? (What is the function get_token_user_sub() supposed to do?)

UML/XMI 파일을 StarUML로 가져오는 방법은 무엇입니까? (How to import any UML/XMI files to StarUML?)

문서화 오류 Jazzy "0% 문서화되지 않은 기호가 포함된 문서 적용 범위" (documenting error Jazzy "0% documentation coverage with 0 undocumented symbols")

간단한 방법으로 javadoc을 내보내거나 구문 분석하는 도구가 있습니까? (Are there any tools to export/parse javadocs in simple way?)

JSON 스키마 기반 문서 (Documentation based on JSON Schema)







코멘트