Skip to content

Commit

Permalink
Add spec version to Libdoc JSON specs (and schema).
Browse files Browse the repository at this point in the history
Part of #4281.
  • Loading branch information
pekkaklarck committed Apr 27, 2022
1 parent af48416 commit 2f76897
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 13 additions & 0 deletions doc/schema/libdoc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"title": "Libdoc",
"description": "Libdoc JSON spec file schema.\n\nCompatible with JSON Schema Draft 2020-12.",
"type": "object",
"properties": {
"specversion": {
"$ref": "#/definitions/SpecVersion"
},
"name": {
"title": "Name",
"type": "string"
Expand Down Expand Up @@ -75,6 +79,7 @@
}
},
"required": [
"specversion",
"name",
"doc",
"version",
Expand All @@ -91,6 +96,14 @@
],
"$schema": "https://json-schema.org/draft/2020-12/schema",
"definitions": {
"SpecVersion": {
"title": "SpecVersion",
"description": "Version of the spec.",
"enum": [
1
],
"type": "integer"
},
"DocumentationType": {
"title": "DocumentationType",
"description": "Type of the doc: LIBRARY or RESOURCE.",
Expand Down
11 changes: 10 additions & 1 deletion doc/schema/libdoc_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from pydantic import BaseModel, Field, PositiveInt


class SpecVersion(int, Enum):
"""Version of the spec."""
VERSION = 1


class DocumentationType(str, Enum):
"""Type of the doc: LIBRARY or RESOURCE."""
LIBRARY = 'LIBRARY'
Expand Down Expand Up @@ -105,7 +110,11 @@ class TypeDoc(BaseModel):


class Libdoc(BaseModel):
#specversion
"""Libdoc JSON spec file schema.
Compatible with JSON Schema Draft 2020-12.
"""
specversion: SpecVersion
name: str
doc: str
version: str
Expand Down
1 change: 1 addition & 0 deletions src/robot/libdocpkg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def convert_docs_to_html(self):

def to_dictionary(self):
return {
'specversion': 1,
'name': self.name,
'doc': self.doc,
'version': self.version,
Expand Down

0 comments on commit 2f76897

Please sign in to comment.