rbren / fhir-swagger

Generate Swagger from a FHIR conformance profile
MIT License
60 stars 32 forks source link

support for DSTU3 Resources #2

Closed Nikunjksanghavi closed 7 years ago

Nikunjksanghavi commented 8 years ago

I have tried to generate swagger using FHIR DSTU2 server conformance profile and it works perfectly.

But with FHIR DSTU3 conformance profile Its giving following error while execution

D:\svn_repo\FHIR\swagger\fhir_to_swagger>node fhirtoswagger.js
module.js:328
    throw err;
    ^

Error: Cannot find module '../schemas/examples/careteam-example.json'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at module.exports (D:\svn_repo\FHIR\swagger\fhir_to_swagger\node_modules\fhi
r-swagger\lib\schemas.js:28:17)
    at D:\svn_repo\FHIR\swagger\fhir_to_swagger\node_modules\fhir-swagger\lib\co
nformance-to-swagger.js:161:54
    at Array.forEach (native)
    at Object.Converter.convert.conf [as convert] (D:\svn_repo\FHIR\swagger\fhir
_to_swagger\node_modules\fhir-swagger\lib\conformance-to-swagger.js:24:15)
    at Request._callback (D:\svn_repo\FHIR\swagger\fhir_to_swagger\node_modules\
fhir-swagger\index.js:21:29)
    at Request.self.callback (D:\svn_repo\FHIR\swagger\fhir_to_swagger\node_modu
les\fhir-swagger\node_modules\request\request.js:199:22)

Does the module provides support for the new resources added in DSTU3? Or please guide if there is a way I can extend it to support them?

rbren commented 8 years ago

The way fhir-swagger generates JSON schema for each object is by looking at examples downloaded from this page: https://www.hl7.org/fhir/downloads.html

Once examples/schemas are published for DSTU3 we can add them to ./schemas/examples. Alternatively you could hand-code schemas for the new DSTU3 objects. Depending on what you need the Swagger for we could also fail silently if the schema isn't found.

cladius commented 8 years ago

The sample schemas for STU3 are actually available at http://hl7.org/fhir/2016May/downloads.html.

rbren commented 8 years ago

OK great, I've set up a new branch (dstu3) that adds the examples. Can you try it out?

npm install https://github.com/bobby-brennan/fhir-swagger#dstu3

Bobby Brennan bobby.brennan@gmail.com

On Tue, Apr 26, 2016 at 1:14 AM, Cladius Fernando notifications@github.com wrote:

The sample schemas for STU3 are actually available at http://hl7.org/fhir/2016May/downloads.html.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/bobby-brennan/fhir-swagger/issues/2#issuecomment-214618338

Nikunjksanghavi commented 8 years ago

I have tried to generated swagger for dstu3 version Its giving following error while execution

D:\Git_SVN\fhir-swagger dstu3>node fhirtoswagger.js
module.js:328
    throw err;
    ^

Error: Cannot find module '../schemas/examples/compartmentdefinition-example.jso
n'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at module.exports (D:\Git_SVN\fhir-swagger dstu3  \node_modules\fhir-swa
gger\lib\schemas.js:34:17)
    at D:\Git_SVN\fhir-swagger dstu3  \node_modules\fhir-swagger\lib\conform
ance-to-swagger.js:41:50
    at Array.forEach (native)
    at Object.Converter.convert.conf [as convert] (D:\Git_SVN\fhir-swagger dstu3
  \node_modules\fhir-swagger\lib\conformance-to-swagger.js:39:13)
    at Request._callback (D:\Git_SVN\fhir-swagger dstu3\node_modules\fhir-
swagger\index.js:21:29)
    at Request.self.callback (D:\Git_SVN\fhir-swagger dstu3  \node_modules\f
hir-swagger\node_modules\request\request.js:200:22)

And fhirtoswagger.js file contains

var fhirToSwagger = require('fhir-swagger')
var fs = require("fs");
var options = {
  fhir_url: 'http://fhirtest.uhn.ca/baseDstu3/',
  conformance_path: 'metadata?_format=application/json',
}
fhirToSwagger(options, function(err, swagger) {
  fs.writeFile( "localswagger.json", JSON.stringify( swagger ), "utf8" );
  //console.log("Generated swagger_psl_fhir.json Sucessfully");
  console.log("err:"+err);
  console.log("swagger:"+swagger);
})

This time error is for another resource example.json file which is not found while execution.

rbren commented 8 years ago

Hmm OK. I should make these warnings rather than failures anyways. Will do that and ping you when ready

Bobby Brennan bobby.brennan@gmail.com

On Fri, Apr 29, 2016 at 6:29 AM, Nikunj Sanghavi notifications@github.com wrote:

I have tried to generated swagger for dstu3 version Its giving following error while execution

D:\Git_SVN\fhir-swagger dstu3>node fhirtoswagger.js module.js:328 throw err; ^

Error: Cannot find module '../schemas/examples/compartmentdefinition-example.jso n' at Function.Module._resolveFilename (module.js:326:15) at Function.Module._load (module.js:277:25) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at module.exports (D:\Git_SVN\fhir-swagger dstu3 \node_modules\fhir-swa gger\lib\schemas.js:34:17) at D:\Git_SVN\fhir-swagger dstu3 \node_modules\fhir-swagger\lib\conform ance-to-swagger.js:41:50 at Array.forEach (native) at Object.Converter.convert.conf [as convert](D:Git_SVNfhir-swagger dstu3 node_modulesfhir-swaggerlibconformance-to-swagger.js:39:13) at Request._callback (D:\Git_SVN\fhir-swagger dstu3\node_modules\fhir- swagger\index.js:21:29) at Request.self.callback (D:\Git_SVN\fhir-swagger dstu3 \node_modules\f hir-swagger\node_modules\request\request.js:200:22)

And fhirtoswagger.js file contains

var fhirToSwagger = require('fhir-swagger') var fs = require("fs"); var options = { fhir_url: 'http://fhirtest.uhn.ca/baseDstu3/', conformance_path: 'metadata?_format=application/json', } fhirToSwagger(options, function(err, swagger) { fs.writeFile( "localswagger.json", JSON.stringify( swagger ), "utf8" ); //console.log("Generated swagger_psl_fhir.json Sucessfully"); console.log("err:"+err); console.log("swagger:"+swagger); })

This time error is for another resource example.json file which is not found while execution.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/bobby-brennan/fhir-swagger/issues/2#issuecomment-215679816

emreavsar commented 7 years ago

something happened here in the meanwhile?

rbren commented 7 years ago

Hi all,

I've added dstu3 examples into the master branch. You can use them by adding the --dstu3 flag. Be sure to update to the latest version (2.1.0).

I've also turned the "missing schema" failures into warnings.

I'm going to create a separate issue for converting the XSD into JSON Schema (rather than using JSON examples). Unfortunately I haven't gotten either xsd2json or jsonix schema compiler to work.