From 68bcbf1e6e5862cd11a1c5065417d358ef75d6b9 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 15 Aug 2018 13:58:40 -0700 Subject: codegen python with core_id --- python/fatcat_client/models/release_entity.py | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'python/fatcat_client/models') diff --git a/python/fatcat_client/models/release_entity.py b/python/fatcat_client/models/release_entity.py index 3412ca92..79e2c64f 100644 --- a/python/fatcat_client/models/release_entity.py +++ b/python/fatcat_client/models/release_entity.py @@ -48,6 +48,7 @@ class ReleaseEntity(object): 'wikidata_qid': 'str', 'pmcid': 'str', 'pmid': 'str', + 'core_id': 'str', 'isbn13': 'str', 'doi': 'str', 'release_date': 'date', @@ -78,6 +79,7 @@ class ReleaseEntity(object): 'wikidata_qid': 'wikidata_qid', 'pmcid': 'pmcid', 'pmid': 'pmid', + 'core_id': 'core_id', 'isbn13': 'isbn13', 'doi': 'doi', 'release_date': 'release_date', @@ -96,7 +98,7 @@ class ReleaseEntity(object): 'extra': 'extra' } - def __init__(self, abstracts=None, refs=None, contribs=None, language=None, publisher=None, pages=None, issue=None, volume=None, wikidata_qid=None, pmcid=None, pmid=None, isbn13=None, doi=None, release_date=None, release_status=None, release_type=None, container_id=None, files=None, container=None, work_id=None, title=None, state=None, ident=None, revision=None, redirect=None, editgroup_id=None, extra=None): # noqa: E501 + def __init__(self, abstracts=None, refs=None, contribs=None, language=None, publisher=None, pages=None, issue=None, volume=None, wikidata_qid=None, pmcid=None, pmid=None, core_id=None, isbn13=None, doi=None, release_date=None, release_status=None, release_type=None, container_id=None, files=None, container=None, work_id=None, title=None, state=None, ident=None, revision=None, redirect=None, editgroup_id=None, extra=None): # noqa: E501 """ReleaseEntity - a model defined in Swagger""" # noqa: E501 self._abstracts = None @@ -110,6 +112,7 @@ class ReleaseEntity(object): self._wikidata_qid = None self._pmcid = None self._pmid = None + self._core_id = None self._isbn13 = None self._doi = None self._release_date = None @@ -150,6 +153,8 @@ class ReleaseEntity(object): self.pmcid = pmcid if pmid is not None: self.pmid = pmid + if core_id is not None: + self.core_id = core_id if isbn13 is not None: self.isbn13 = isbn13 if doi is not None: @@ -415,6 +420,27 @@ class ReleaseEntity(object): self._pmid = pmid + @property + def core_id(self): + """Gets the core_id of this ReleaseEntity. # noqa: E501 + + + :return: The core_id of this ReleaseEntity. # noqa: E501 + :rtype: str + """ + return self._core_id + + @core_id.setter + def core_id(self, core_id): + """Sets the core_id of this ReleaseEntity. + + + :param core_id: The core_id of this ReleaseEntity. # noqa: E501 + :type: str + """ + + self._core_id = core_id + @property def isbn13(self): """Gets the isbn13 of this ReleaseEntity. # noqa: E501 -- cgit v1.2.3 From b83347388d17dfd58c9f3d123d3d96d050ca6e9b Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 16 Aug 2018 09:42:55 -0700 Subject: ORCIDs can end in X character --- fatcat-openapi2.yml | 2 +- python/fatcat_client/api/default_api.py | 4 ++-- python/fatcat_client/models/creator_entity.py | 4 ++-- rust/fatcat-api/README.md | 2 +- rust/fatcat-api/api.yaml | 2 +- rust/fatcat-api/api/swagger.yaml | 6 +++--- rust/src/api_helpers.rs | 10 +++++++++- 7 files changed, 19 insertions(+), 11 deletions(-) (limited to 'python/fatcat_client/models') diff --git a/fatcat-openapi2.yml b/fatcat-openapi2.yml index 7ec91bad..524333ce 100644 --- a/fatcat-openapi2.yml +++ b/fatcat-openapi2.yml @@ -37,7 +37,7 @@ x-issn: &FATCATISSN x-orcid: &FATCATORCID type: string example: "0000-0002-1825-0097" - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{4}" + pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" minLength: 19 maxLength: 19 diff --git a/python/fatcat_client/api/default_api.py b/python/fatcat_client/api/default_api.py index b7f23e25..acd33c88 100644 --- a/python/fatcat_client/api/default_api.py +++ b/python/fatcat_client/api/default_api.py @@ -3255,8 +3255,8 @@ class DefaultApi(object): if ('orcid' in params and len(params['orcid']) < 19): raise ValueError("Invalid value for parameter `orcid` when calling `lookup_creator`, length must be greater than or equal to `19`") # noqa: E501 - if 'orcid' in params and not re.search('\\d{4}-\\d{4}-\\d{4}-\\d{4}', params['orcid']): # noqa: E501 - raise ValueError("Invalid value for parameter `orcid` when calling `lookup_creator`, must conform to the pattern `/\\d{4}-\\d{4}-\\d{4}-\\d{4}/`") # noqa: E501 + if 'orcid' in params and not re.search('\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]', params['orcid']): # noqa: E501 + raise ValueError("Invalid value for parameter `orcid` when calling `lookup_creator`, must conform to the pattern `/\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]/`") # noqa: E501 collection_formats = {} path_params = {} diff --git a/python/fatcat_client/models/creator_entity.py b/python/fatcat_client/models/creator_entity.py index a9e459ee..de096281 100644 --- a/python/fatcat_client/models/creator_entity.py +++ b/python/fatcat_client/models/creator_entity.py @@ -139,8 +139,8 @@ class CreatorEntity(object): raise ValueError("Invalid value for `orcid`, length must be less than or equal to `19`") # noqa: E501 if orcid is not None and len(orcid) < 19: raise ValueError("Invalid value for `orcid`, length must be greater than or equal to `19`") # noqa: E501 - if orcid is not None and not re.search('\\d{4}-\\d{4}-\\d{4}-\\d{4}', orcid): # noqa: E501 - raise ValueError("Invalid value for `orcid`, must be a follow pattern or equal to `/\\d{4}-\\d{4}-\\d{4}-\\d{4}/`") # noqa: E501 + if orcid is not None and not re.search('\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]', orcid): # noqa: E501 + raise ValueError("Invalid value for `orcid`, must be a follow pattern or equal to `/\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]/`") # noqa: E501 self._orcid = orcid diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md index af4e6a5b..1e382370 100644 --- a/rust/fatcat-api/README.md +++ b/rust/fatcat-api/README.md @@ -13,7 +13,7 @@ To see how to make this your own, look here: [README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - API version: 0.1.0 -- Build date: 2018-08-15T00:04:03.771Z +- Build date: 2018-08-16T16:42:27.600Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml index 7ec91bad..524333ce 100644 --- a/rust/fatcat-api/api.yaml +++ b/rust/fatcat-api/api.yaml @@ -37,7 +37,7 @@ x-issn: &FATCATISSN x-orcid: &FATCATORCID type: string example: "0000-0002-1825-0097" - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{4}" + pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" minLength: 19 maxLength: 19 diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml index c572fd29..021594c0 100644 --- a/rust/fatcat-api/api/swagger.yaml +++ b/rust/fatcat-api/api/swagger.yaml @@ -612,7 +612,7 @@ paths: type: "string" maxLength: 19 minLength: 19 - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{4}" + pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" formatString: "\\\"{}\\\"" example: "\"orcid_example\".to_string()" responses: @@ -2061,7 +2061,7 @@ definitions: example: "0000-0002-1825-0097" minLength: 19 maxLength: 19 - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{4}" + pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" surname: type: "string" given_name: @@ -3180,7 +3180,7 @@ x-issn: x-orcid: type: "string" example: "0000-0002-1825-0097" - pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{4}" + pattern: "\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]" minLength: 19 maxLength: 19 x-entity-props: diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs index 489631b3..020aad76 100644 --- a/rust/src/api_helpers.rs +++ b/rust/src/api_helpers.rs @@ -181,7 +181,7 @@ pub fn check_issn(raw: &str) -> Result<()> { pub fn check_orcid(raw: &str) -> Result<()> { lazy_static! { - static ref RE: Regex = Regex::new(r"^\d{4}-\d{4}-\d{4}-\d{4}$").unwrap(); + static ref RE: Regex = Regex::new(r"^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$").unwrap(); } if RE.is_match(raw) { Ok(()) @@ -193,6 +193,14 @@ pub fn check_orcid(raw: &str) -> Result<()> { } } +#[test] +fn test_check_orcid() { + assert!(check_orcid("0123-4567-3456-6789").is_ok()); + assert!(check_orcid("0123-4567-3456-678X").is_ok()); + assert!(check_orcid("01234567-3456-6780").is_err()); + assert!(check_orcid("0x23-4567-3456-6780").is_err()); +} + // TODO: make the above checks "more correct" // TODO: check ISBN-13 // TODO: check hashes (SHA-1, etc) -- cgit v1.2.3