LD4P / sinopia_server

[Deprecated - switching to MongoDB] Sinopia Back-end CRUD Service. LDP-inspired, HTTP Server taking JSON-LD resources & administrative metadata.
Apache License 2.0
1 stars 1 forks source link

Allow call to getResourceWithHttpInfo to return plain json #76

Closed jgreben closed 5 years ago

jgreben commented 5 years ago

For a non-rdf resource (e.g. profile or resource template) we want the return type to be the json instead of json+ld

e.g. similar to the command line curls: curl -H "Accept:application/json" http://localhost:8080/repository/ld4p/Note

instead of curl -H "Accept:application/ld+json" http://localhost:8080/repository/ld4p/Note

Blocks LD4P/sinopia_editor#309 Blocks LD4P/sinopia_editor#418

jgreben commented 5 years ago

@jmartin-sul I added this function to LDPApi.js in the meantime to get things working:

/**
     * Get metadata (RDF) for a given resource.
     * Get serialization of JSON for a given NON-RDF resource.
     * @param {String} groupID The group who is defining it's own resources or graph within Sinopia.
     * @param {String} resourceID The UUID for the resource defined and managed within Sinopia.
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/Resource} and HTTP response
     */
    this.getNonRdfResourceWithHttpInfo = function(groupID, resourceID) {
      var postBody = null;

      // verify the required parameter 'groupID' is set
      if (groupID === undefined || groupID === null) {
        throw new Error("Missing the required parameter 'groupID' when calling getResource");
      }

      // verify the required parameter 'resourceID' is set
      if (resourceID === undefined || resourceID === null) {
        throw new Error("Missing the required parameter 'resourceID' when calling getResource");
      }

      var pathParams = {
        'groupID': groupID,
        'resourceID': resourceID
      };
      var queryParams = {
      };
      var collectionQueryParams = {
      };
      var headerParams = {
      };
      var formParams = {
      };

      var authNames = ['RemoteUser'];
      var contentTypes = ['application/json'];
      var accepts = ['application/json'];
      var returnType = Resource;

      return this.apiClient.callApi(
        '/repository/{groupID}/{resourceID}', 'GET',
        pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType
      );
    }
jmartin-sul commented 5 years ago

@jgreben: ok, i published an updated version of the node package (3.0.0-beta). will bump to 3.0.0 proper once there are tests for RDF resource creation and retrieval.

took the liberty of publishing before PR merge to help unblock you, but can bump to 3.0.0-beta2 or something if PR feedback necessitates changes.

(oh, also, i'm jmartin-sul on here, sorry, confusing, too many usernames 😆)