Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open API to Hydra Parser #149

Closed
1 of 2 tasks
suryatejreddy opened this issue Mar 2, 2018 · 11 comments
Closed
1 of 2 tasks

Open API to Hydra Parser #149

suryatejreddy opened this issue Mar 2, 2018 · 11 comments

Comments

@suryatejreddy
Copy link
Contributor

I'm submitting a

  • bug report.
  • feature request.

To implement this, we can use existing Hydrus classes to create objects from the Open API doc. The following workflow was recommended by @Mec-iS .
OpenAPI YAML -> hydrus classes -> HYDRA ApiDoc
I am currently working on porting the basic HYDRA functionalities (GET, PUT, POST methods; classes, collections)

More suggestions are welcome.

Do you want to work on this issue?

yes

@Mec-iS
Copy link
Contributor

Mec-iS commented Mar 4, 2018

NOTE: In the beginning it is possible to start with a Hydra ApiDoc >> OpenAPI parser if it is an easier way

@suryatejreddy
Copy link
Contributor Author

suryatejreddy commented Mar 4, 2018

@Mec-iS could you elaborate on the Hydra ApiDoc >> OpenAPI parser. So you want to implement a parser that converts a Hydra ApiDoc to an OpenAPI? I have tried writing python classes to parse OpenAPI. I am stuck at the schema object in OpenAPI. Trying to figure out a way to represent schema objects (that are returned and requested) as python objects.

@Mec-iS
Copy link
Contributor

Mec-iS commented Mar 4, 2018

Probably it is too difficult for now to code a parser OpenAPI->ApiDoc. Instead doing an ApiDoc->OpenAPI one may be doable.

@suryatejreddy
Copy link
Contributor Author

suryatejreddy commented Mar 4, 2018

Okay. Any suggestions on how to start? @Mec-iS The easiest approach i see is printing the OpenAPI doc directly from the hydrus classes.

@Mec-iS
Copy link
Contributor

Mec-iS commented Mar 4, 2018

Exactly.

hydrus is already a parser from JSON-LD (HydraClasses) to Python classes. From these Python classes it is needed to create an OpenAPI-compliant document (as JSON or YAML file).

@suryatejreddy
Copy link
Contributor Author

suryatejreddy commented Mar 12, 2018

A get request on /serverapi/dummyClassCollection returns the following json

{
  "@context": "/serverapi/contexts/dummyClassCollection.jsonld", 
  "@id": "/serverapi/dummyClassCollection/", 
  "@type": "dummyClassCollection", 
  "members": [
    {
      "@id": "/serverapi/dummyClassCollection/1", 
      "@type": "dummyClass"
    }
  ]
}

However, there is no way to access the dummyClass object. Because /serverapi/dummyClassCollection/1 returns the following error.

{
"message": "The method is not allowed for the requested URL."
}

Shouldn't the first get method return a list of dummyClassColelction items with the respective properties?
Or is there something i am missing out on? @Mec-iS

I am trying to convert the Collection endpoints to OpenAPI path objects and then develop a web interface for hydrus where users can view the HydraAPI and make changes just like swagger hub for OpenAPI. Can i start writing a proposal for this?

@chrizandr
Copy link
Member

Actually this was done to make the server similar to Markus's issues API. You can check it out on his website. You could return IDs to access each instance separately or give a list of instances, both are possible but we went ahead with the former.

As for the error message, better if you open an issue about it.

@Mec-iS
Copy link
Contributor

Mec-iS commented Mar 14, 2018

@suryatejreddy The reason for an Hyperlinked API (API supporting Hypermedia) is that some of the endpoints can return links to other resources instead of plain data. Collections as you have described them are implemented to return only hypermedia, leaving to the client the possibility of going and fetching the full object with the properties. (This is also how the Github API works, take a look for some examples).

@vaibhavchellani
Copy link
Contributor

@Mec-iS the Open Api documentation that has to be imported and converted to Hydra API documentation has to be given in YAML/JSON or both ? What would be the best approach ?

@Mec-iS
Copy link
Contributor

Mec-iS commented Mar 22, 2018

This is not a big difference as YAML can be easily re-serialized into JSON. Start with JSON that is closer to JSON-LD.

@chrizandr
Copy link
Member

Added to #193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants