Skip to content

Commit 8485adf

Browse files
committed
Merge branch 'develop' of github.com:HTTP-APIs/hydra-python-core into develop
2 parents b1205f2 + f89be9b commit 8485adf

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

hydra_python_core/doc_maker.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ def check_namespace(id_: str = None) -> str:
374374
:param id_ The id to check
375375
:return: correct url
376376
"""
377-
if id_.find(DocUrl.doc_url) == -1 and id_ != "null" and id_.find('?resource=') != -1:
378-
id_ = "{}{}".format(DocUrl.doc_url, id_.split('?resource=')[-1])
377+
if id_.find(DocUrl.doc_url) == -1 and id_ != "null":
378+
if id_.find('?resource=') != -1:
379+
resource_name = id_.split('?resource=')[-1]
380+
id_ = "{}{}".format(DocUrl.doc_url, resource_name)
381+
elif id_.find('#type') != -1:
382+
id_ = "{}{}".format(DocUrl.doc_url, id_.split('#')[-1])
383+
else:
384+
return id_
379385
return id_

hydra_python_core/doc_writer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,12 @@ def __init__(self, base_url: str, entrypoint: str) -> None:
389389
"""Initialize the Entrypoint."""
390390
self.url = base_url
391391
self.api = entrypoint
392-
class_id = "{}?resource=EntryPoint".format(urljoin(self.url, self.api))
392+
class_id = "{}#EntryPoint".format(urljoin(self.url, self.api))
393393
self.entrypoint = HydraClass("EntryPoint", "The main entry point or homepage of the API.",
394394
_id=class_id)
395395
self.entrypoint.add_supported_op(EntryPointOp(
396396
"_:entry_point".format(base_url), "GET", "The APIs main entry point.", None, None,
397-
type_="{}/{}?resource=EntryPoint".format(base_url, entrypoint)))
397+
type_="{}/{}#EntryPoint".format(base_url, entrypoint)))
398398
self.context = Context(
399399
"{}{}".format(
400400
base_url,
@@ -673,7 +673,8 @@ def __init__(self, code: int, id_: str = None, title: str = "", desc: str = "")
673673
def generate(self, status_type: str = "Status") -> Dict[str, Any]:
674674
"""Get as Python dict."""
675675
status = {
676-
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
676+
"@context": ("https://raw.githubusercontent.com/HydraCG/Specifications"
677+
"/master/spec/latest/core/core.jsonld"),
677678
"@type": status_type,
678679
"statusCode": self.code,
679680
"title": self.title,

samples/doc_writer_sample_output.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"method": "POST",
7878
"possibleStatus": [
7979
{
80-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
80+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
8181
"@type": "Status",
8282
"description": "dummyClass updated.",
8383
"statusCode": 200,
@@ -98,7 +98,7 @@
9898
"method": "DELETE",
9999
"possibleStatus": [
100100
{
101-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
101+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
102102
"@type": "Status",
103103
"description": "dummyClass deleted.",
104104
"statusCode": 200,
@@ -116,7 +116,7 @@
116116
"method": "PUT",
117117
"possibleStatus": [
118118
{
119-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
119+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
120120
"@type": "Status",
121121
"description": "dummyClass successfully added.",
122122
"statusCode": 201,
@@ -134,7 +134,7 @@
134134
"method": "GET",
135135
"possibleStatus": [
136136
{
137-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
137+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
138138
"@type": "Status",
139139
"description": "dummyClass returned.",
140140
"statusCode": 200,
@@ -186,7 +186,7 @@
186186
"method": "POST",
187187
"possibleStatus": [
188188
{
189-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
189+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
190190
"@type": "Status",
191191
"description": "singleClass changed.",
192192
"statusCode": 200,
@@ -204,7 +204,7 @@
204204
"method": "DELETE",
205205
"possibleStatus": [
206206
{
207-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
207+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
208208
"@type": "Status",
209209
"description": "singleClass deleted.",
210210
"statusCode": 200,
@@ -222,7 +222,7 @@
222222
"method": "PUT",
223223
"possibleStatus": [
224224
{
225-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
225+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
226226
"@type": "Status",
227227
"description": "singleClass successfully added.",
228228
"statusCode": 201,
@@ -240,7 +240,7 @@
240240
"method": "GET",
241241
"possibleStatus": [
242242
{
243-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
243+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
244244
"@type": "Status",
245245
"description": "singleClass returned.",
246246
"statusCode": 200,
@@ -308,7 +308,7 @@
308308
"method": "GET",
309309
"possibleStatus": [
310310
{
311-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
311+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
312312
"@type": "Status",
313313
"description": "anotherSingleClass returned.",
314314
"statusCode": 200,
@@ -387,7 +387,7 @@
387387
"method": "PUT",
388388
"possibleStatus": [
389389
{
390-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
390+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
391391
"@type": "Status",
392392
"description": "A new member in Extraclasses created",
393393
"statusCode": 201,
@@ -406,7 +406,7 @@
406406
"method": "POST",
407407
"possibleStatus": [
408408
{
409-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
409+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
410410
"@type": "Status",
411411
"description": "If the entity was updatedfrom Extraclasses.",
412412
"statusCode": 200,
@@ -425,7 +425,7 @@
425425
"method": "DELETE",
426426
"possibleStatus": [
427427
{
428-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
428+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
429429
"@type": "Status",
430430
"description": "If entity was deletedsuccessfully from Extraclasses.",
431431
"statusCode": 200,
@@ -479,7 +479,7 @@
479479
"method": "PUT",
480480
"possibleStatus": [
481481
{
482-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
482+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
483483
"@type": "Status",
484484
"description": "A new member in dummyclasses created",
485485
"statusCode": 201,
@@ -498,7 +498,7 @@
498498
"method": "POST",
499499
"possibleStatus": [
500500
{
501-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
501+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
502502
"@type": "Status",
503503
"description": "If the entity was updatedfrom dummyclasses.",
504504
"statusCode": 200,
@@ -517,7 +517,7 @@
517517
"method": "DELETE",
518518
"possibleStatus": [
519519
{
520-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
520+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
521521
"@type": "Status",
522522
"description": "If entity was deletedsuccessfully from dummyclasses.",
523523
"statusCode": 200,
@@ -542,13 +542,13 @@
542542
"title": "dummyclasses"
543543
},
544544
{
545-
"@id": "http://hydrus.com/api?resource=EntryPoint",
545+
"@id": "http://hydrus.com/api#EntryPoint",
546546
"@type": "hydra:Class",
547547
"description": "The main entry point or homepage of the API.",
548548
"supportedOperation": [
549549
{
550550
"@id": "_:entry_point",
551-
"@type": "http://hydrus.com//api?resource=EntryPoint",
551+
"@type": "http://hydrus.com//api#EntryPoint",
552552
"description": "The APIs main entry point.",
553553
"expects": "null",
554554
"expectsHeader": [],
@@ -580,7 +580,7 @@
580580
"method": "POST",
581581
"possibleStatus": [
582582
{
583-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
583+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
584584
"@type": "Status",
585585
"description": "singleClass changed.",
586586
"statusCode": 200,
@@ -600,7 +600,7 @@
600600
"method": "DELETE",
601601
"possibleStatus": [
602602
{
603-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
603+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
604604
"@type": "Status",
605605
"description": "singleClass deleted.",
606606
"statusCode": 200,
@@ -620,7 +620,7 @@
620620
"method": "PUT",
621621
"possibleStatus": [
622622
{
623-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
623+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
624624
"@type": "Status",
625625
"description": "singleClass successfully added.",
626626
"statusCode": 201,
@@ -640,7 +640,7 @@
640640
"method": "GET",
641641
"possibleStatus": [
642642
{
643-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
643+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
644644
"@type": "Status",
645645
"description": "singleClass returned.",
646646
"statusCode": 200,
@@ -677,7 +677,7 @@
677677
"method": "GET",
678678
"possibleStatus": [
679679
{
680-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
680+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
681681
"@type": "Status",
682682
"description": "anotherSingleClass returned.",
683683
"statusCode": 200,
@@ -728,7 +728,7 @@
728728
"method": "PUT",
729729
"possibleStatus": [
730730
{
731-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
731+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
732732
"@type": "Status",
733733
"description": "A new member in Extraclasses created",
734734
"statusCode": 201,
@@ -747,7 +747,7 @@
747747
"method": "POST",
748748
"possibleStatus": [
749749
{
750-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
750+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
751751
"@type": "Status",
752752
"description": "If the entity was updatedfrom Extraclasses.",
753753
"statusCode": 200,
@@ -766,7 +766,7 @@
766766
"method": "DELETE",
767767
"possibleStatus": [
768768
{
769-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
769+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
770770
"@type": "Status",
771771
"description": "If entity was deletedsuccessfully from Extraclasses.",
772772
"statusCode": 200,
@@ -817,7 +817,7 @@
817817
"method": "PUT",
818818
"possibleStatus": [
819819
{
820-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
820+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
821821
"@type": "Status",
822822
"description": "A new member in dummyclasses created",
823823
"statusCode": 201,
@@ -836,7 +836,7 @@
836836
"method": "POST",
837837
"possibleStatus": [
838838
{
839-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
839+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
840840
"@type": "Status",
841841
"description": "If the entity was updatedfrom dummyclasses.",
842842
"statusCode": 200,
@@ -855,7 +855,7 @@
855855
"method": "DELETE",
856856
"possibleStatus": [
857857
{
858-
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
858+
"@context": "https://raw.githubusercontent.com/HydraCG/Specifications/master/spec/latest/core/core.jsonld",
859859
"@type": "Status",
860860
"description": "If entity was deletedsuccessfully from dummyclasses.",
861861
"statusCode": 200,

0 commit comments

Comments
 (0)