From 65bc8ef4e5221555353112027c643a2d97984cc3 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 25 May 2016 18:34:31 +0300 Subject: [PATCH 01/20] Migrate to Typescript (not finished yet) --- build/paths.js | 2 +- build/tasks/build.js | 29 +- demo/index.html | 8 +- demo/main.css | 4 +- demo/swagger.yaml | 828 ++++++++++++++++++ .../ApiInfo/{api-info.js => api-info.ts} | 12 +- .../ApiLogo/{api-logo.js => api-logo.ts} | 11 +- ...son-schema-lazy.js => json-schema-lazy.ts} | 26 +- .../{json-schema.js => json-schema.ts} | 24 +- .../Method/{method.js => method.ts} | 15 +- .../{methods-list.js => methods-list.ts} | 12 +- .../{params-list.js => params-list.ts} | 13 +- lib/components/Redoc/{redoc.js => redoc.ts} | 31 +- ...{request-samples.js => request-samples.ts} | 19 +- .../{responses-list.js => responses-list.ts} | 9 +- ...ponses-samples.js => responses-samples.ts} | 9 +- .../{schema-sample.js => schema-sample.ts} | 11 +- .../SideMenu/{side-menu.js => side-menu.ts} | 24 +- lib/components/{base.js => base.ts} | 10 +- lib/components/{index.js => index.ts} | 0 lib/{index.js => index.ts} | 2 +- lib/services/events.service.js | 10 - lib/services/events.service.ts | 8 + lib/services/hash.service.spec.js | 2 +- .../{hash.service.js => hash.service.ts} | 9 +- lib/services/index.js | 7 - lib/services/index.ts | 7 + .../{menu.service.js => menu.service.ts} | 21 +- ...{options.service.js => options.service.ts} | 7 +- .../{scroll.service.js => scroll.service.ts} | 13 +- .../components/DropDown/drop-down.css.shim.ts | 0 .../DropDown/{drop-down.js => drop-down.ts} | 18 +- .../{sticky-sidebar.js => sticky-sidebar.ts} | 16 +- .../components/Tabs/{tabs.js => tabs.ts} | 24 +- lib/shared/components/Zippy/zippy.css.shim.ts | 5 + lib/shared/components/Zippy/zippy.js | 29 - lib/shared/components/Zippy/zippy.ts | 25 + lib/shared/components/{index.js => index.ts} | 0 ...nFormatterPipe.js => JsonFormatterPipe.ts} | 0 lib/utils/{JsonPointer.js => JsonPointer.ts} | 26 +- .../{SchemaManager.js => SchemaManager.ts} | 15 +- .../{browser-update.js => browser-update.ts} | 2 +- lib/utils/{helpers.js => helpers.ts} | 0 lib/utils/{pipes.js => pipes.ts} | 13 +- lib/utils/prismjs-bundle.ts | 0 .../{swagger-defs.js => swagger-defs.ts} | 0 package.json | 42 + rollup.config.js | 58 ++ system.config.js | 13 +- tsconfig.json | 20 + typings.json | 11 + typings/dropkick.d.ts | 7 + typings/globals/jasmine/index.d.ts | 501 +++++++++++ typings/globals/jasmine/typings.json | 8 + typings/globals/json-pointer/index.d.ts | 80 ++ typings/globals/json-pointer/typings.json | 8 + typings/index.d.ts | 4 + typings/json-schema-instantiator.d.ts | 6 + typings/json-schema-ref-parser.d.ts | 6 + typings/marked.d.ts | 7 + typings/modules/chai/index.d.ts | 547 ++++++++++++ typings/modules/chai/typings.json | 21 + typings/scrollparent.d.ts | 6 + 63 files changed, 2452 insertions(+), 249 deletions(-) create mode 100644 demo/swagger.yaml rename lib/components/ApiInfo/{api-info.js => api-info.ts} (58%) rename lib/components/ApiLogo/{api-logo.js => api-logo.ts} (61%) rename lib/components/JsonSchema/{json-schema-lazy.js => json-schema-lazy.ts} (73%) rename lib/components/JsonSchema/{json-schema.js => json-schema.ts} (95%) rename lib/components/Method/{method.js => method.ts} (83%) rename lib/components/MethodsList/{methods-list.js => methods-list.ts} (79%) rename lib/components/ParamsList/{params-list.js => params-list.ts} (90%) rename lib/components/Redoc/{redoc.js => redoc.ts} (85%) rename lib/components/RequestSamples/{request-samples.js => request-samples.ts} (67%) rename lib/components/ResponsesList/{responses-list.js => responses-list.ts} (87%) rename lib/components/ResponsesSamples/{responses-samples.js => responses-samples.ts} (85%) rename lib/components/SchemaSample/{schema-sample.js => schema-sample.ts} (85%) rename lib/components/SideMenu/{side-menu.js => side-menu.ts} (82%) rename lib/components/{base.js => base.ts} (97%) rename lib/components/{index.js => index.ts} (100%) rename lib/{index.js => index.ts} (80%) delete mode 100644 lib/services/events.service.js create mode 100644 lib/services/events.service.ts rename lib/services/{hash.service.js => hash.service.ts} (73%) delete mode 100644 lib/services/index.js create mode 100644 lib/services/index.ts rename lib/services/{menu.service.js => menu.service.ts} (91%) rename lib/services/{options.service.js => options.service.ts} (94%) rename lib/services/{scroll.service.js => scroll.service.ts} (84%) create mode 100644 lib/shared/components/DropDown/drop-down.css.shim.ts rename lib/shared/components/DropDown/{drop-down.js => drop-down.ts} (50%) rename lib/shared/components/StickySidebar/{sticky-sidebar.js => sticky-sidebar.ts} (78%) rename lib/shared/components/Tabs/{tabs.js => tabs.ts} (78%) create mode 100644 lib/shared/components/Zippy/zippy.css.shim.ts delete mode 100644 lib/shared/components/Zippy/zippy.js create mode 100644 lib/shared/components/Zippy/zippy.ts rename lib/shared/components/{index.js => index.ts} (100%) rename lib/utils/{JsonFormatterPipe.js => JsonFormatterPipe.ts} (100%) rename lib/utils/{JsonPointer.js => JsonPointer.ts} (77%) rename lib/utils/{SchemaManager.js => SchemaManager.ts} (94%) rename lib/utils/{browser-update.js => browser-update.ts} (86%) rename lib/utils/{helpers.js => helpers.ts} (100%) rename lib/utils/{pipes.js => pipes.ts} (89%) create mode 100644 lib/utils/prismjs-bundle.ts rename lib/utils/{swagger-defs.js => swagger-defs.ts} (100%) create mode 100644 rollup.config.js create mode 100644 tsconfig.json create mode 100644 typings.json create mode 100644 typings/dropkick.d.ts create mode 100644 typings/globals/jasmine/index.d.ts create mode 100644 typings/globals/jasmine/typings.json create mode 100644 typings/globals/json-pointer/index.d.ts create mode 100644 typings/globals/json-pointer/typings.json create mode 100644 typings/index.d.ts create mode 100644 typings/json-schema-instantiator.d.ts create mode 100644 typings/json-schema-ref-parser.d.ts create mode 100644 typings/marked.d.ts create mode 100644 typings/modules/chai/index.d.ts create mode 100644 typings/modules/chai/typings.json create mode 100644 typings/scrollparent.d.ts diff --git a/build/paths.js b/build/paths.js index 988f2cc8..ffea6b39 100644 --- a/build/paths.js +++ b/build/paths.js @@ -1,7 +1,7 @@ var path = require('path'); var paths = { - source: 'lib/**/*.js', + source: 'lib/**/*.ts', html: 'lib/**/*.html', scss: 'lib/**/*.scss', sourceEntryPoint: 'lib/index.js', diff --git a/build/tasks/build.js b/build/tasks/build.js index 3ab8725c..692041d9 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -13,6 +13,7 @@ var replace = require('gulp-replace'); var rename = require('gulp-rename'); var argv = require('yargs').argv; var gulpIf = require('gulp-if'); +var sassCopm = require('node-sass'); gulp.task('build', function (callback) { if (argv.skipRebuild) { @@ -20,7 +21,7 @@ gulp.task('build', function (callback) { return callback(); } return runSequence( - 'clean', + //'clean', 'concatPrism', 'bundle', 'concatDeps', @@ -46,11 +47,25 @@ gulp.task('rebuild', function(done) { gulp.task('inlineTemplates', ['sass'], function() { return gulp.src(paths.source, { base: './' }) - .pipe(replace(/'(.*?\.css)'/g, '\'.tmp/$1\'')) - .pipe(inlineNg2Template({ base: '/' })) + .pipe(replace(/'(.*?)\.css'/g, '\'$1.scss\'')) + .pipe(inlineNg2Template({ + base: '/', + useRelativePaths: true, + styleProcessor: compileSass + })) .pipe(gulp.dest(paths.tmp)); }); +function compileSass(ext, file) { + file = file.replace('../../shared/styles/variables', 'lib/shared/styles/variables'); + file = file.replace('json-schema-common', 'lib/components/JsonSchema/json-schema-common'); + file = file.replace('../../shared/styles/share-link', 'lib/shared/styles/share-link'); + file = file.replace('../JsonSchema/lib/components/JsonSchema/json-schema-common', 'lib/components/JsonSchema/json-schema-common'); + file = file.replace('../../styles/variables', 'lib/shared/styles/variables'); + + return sassCopm.renderSync({data: file}).css; +} + var JS_DEPS = argv.prod ? [ 'lib/utils/browser-update.js', 'node_modules/zone.js/dist/zone.min.js', @@ -59,7 +74,7 @@ var JS_DEPS = argv.prod ? [ ]: [ 'lib/utils/browser-update.js', 'node_modules/zone.js/dist/zone.js', - 'node_modules/zone.js/dist/long-stack-trace-zone.js', + //'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/reflect-metadata/Reflect.js', 'node_modules/babel-polyfill/dist/polyfill.js' ]; @@ -73,15 +88,15 @@ gulp.task('sass', function () { }); // concatenate angular2 deps -gulp.task('concatDeps', function() { - return gulp.src(JS_DEPS.concat([outputFileName])) +gulp.task('concatDeps', ['concatPrism'], function() { + return gulp.src(JS_DEPS.concat([path.join(paths.tmp, 'prismjs-bundle.js'), outputFileName])) .pipe(gulpIf(!argv.prod, sourcemaps.init({loadMaps: true}))) .pipe(concat(outputFileName)) .pipe(gulpIf(!argv.prod, sourcemaps.write('.'))) .pipe(gulp.dest('.')) }); -gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(done) { +gulp.task('bundle', function bundle(done) { fs.existsSync('dist') || fs.mkdirSync('dist'); var builder = new Builder('./', 'system.config.js'); diff --git a/demo/index.html b/demo/index.html index cbcd26f1..08627953 100644 --- a/demo/index.html +++ b/demo/index.html @@ -12,13 +12,13 @@ - + - + - + diff --git a/demo/main.css b/demo/main.css index 02ec91ec..e927f4e6 100644 --- a/demo/main.css +++ b/demo/main.css @@ -1,5 +1,5 @@ -@import url(http://fonts.googleapis.com/css?family=Roboto:300,400,700); -@import url(http://fonts.googleapis.com/css?family=Montserrat:300,400); +/*@import url(http://fonts.googleapis.com/css?family=Roboto:300,400,700); +@import url(http://fonts.googleapis.com/css?family=Montserrat:300,400);*/ body { margin: 0; diff --git a/demo/swagger.yaml b/demo/swagger.yaml new file mode 100644 index 00000000..34e3414f --- /dev/null +++ b/demo/swagger.yaml @@ -0,0 +1,828 @@ +swagger: '2.0' +schemes: + - http +host: petstore.swagger.io +basePath: /v2 +info: + description: 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.' + version: 1.0.0 + title: Swagger Petstore + termsOfService: 'http://swagger.io/terms/' + contact: + email: apiteam@swagger.io + x-logo: + url: 'https://rebilly.github.io/ReDoc/petstore-logo.png' + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' +externalDocs: + description: Find out more about Swagger + url: 'http://swagger.io' +tags: + - name: Pagination + x-traitTag: true + description: |- + Sometimes you just can't get enough. For this reason, we've provided a convenient way to access more data in any request for sequential data. Simply call the url in the next_url parameter and we'll respond with the next set of data. + ```json + { + + ... + + "pagination": { + + "next_url": + "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296", + + "next_max_id": "13872296" + + } + + } + ``` + + On views where pagination is present, we also support the `count` + parameter. Simply set this to the number of items you'd like to receive. Note that the default values should be fine for most applications - but if you decide to increase this number there is a maximum value defined on each endpoint. + externalDocs: + description: Find out more + url: 'http://swagger.io' + - name: JSONP + x-traitTag: true + description: "If you're writing an AJAX application, and you'd like to wrap our response with a callback, all you have to do is specify a callback parameter with any API call:\n```\n https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction\n```\nWould respond with:\n```js\ncallbackFunction({\n ...\n});\n``` \n > Example of markdown blockquote" + externalDocs: + description: Find out more + url: 'http://swagger.io' + - name: pet + description: Everything about your Pets + externalDocs: + description: Find out more + url: 'http://swagger.io' + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user + externalDocs: + description: Find out more about our store + url: 'http://swagger.io' +securityDefinitions: + petstore_auth: + type: oauth2 + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + flow: implicit + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header +paths: + /pet: + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + x-code-samples: + - lang: 'C#' + source: | + PetStore.v1.Pet pet = new PetStore.v1.Pet(); + pet.setApiKey("your api key"); + pet.petType = PetStore.v1.Pet.TYPE_DOG; + pet.name = "Rex"; + // set other fields + PetStoreResponse response = pet.create(); + if (response.statusCode == HttpStatusCode.Created) + { + // Successfully created + } + else + { + // Something wrong -- check response for errors + Console.WriteLine(response.getRawResponse()); + } + - lang: PHP + source: "$form = new \\PetStore\\Entities\\Pet();\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->create($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n" + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + consumes: + - application/json + - application/xml + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Pet object that needs to be added to the store + required: true + schema: + $ref: '#/definitions/Pet' + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + x-code-samples: + - lang: PHP + source: "$form = new \\PetStore\\Entities\\Pet();\n$form->setPetId(1);\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->update($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n" + '/pet/{petId}': + get: + tags: + - pet + - JSONP + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + type: integer + format: int64 + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + consumes: + - application/x-www-form-urlencoded + produces: + - application/xml + - application/json + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + type: integer + format: int64 + - name: name + in: formData + description: Updated name of the pet + required: false + type: string + - name: status + in: formData + description: Updated status of the pet + required: false + type: string + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + produces: + - application/xml + - application/json + parameters: + - name: api_key + in: header + required: false + type: string + - name: petId + in: path + description: Pet id to delete + required: true + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + get: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + consumes: + - image/jpeg + - image/png + produces: + - image/jpeg + - image/png + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: file + in: body + description: file to upload + required: false + schema: + type: file + responses: + '200': + description: successful operation + schema: + type: file + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + consumes: + - multipart/form-data + produces: + - application/json + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + type: integer + format: int64 + - name: additionalMetadata + in: formData + description: Additional data to pass to server + required: false + type: string + - name: file + in: formData + description: file to upload + required: false + type: file + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByStatus: + get: + tags: + - pet + - Pagination + - JSONP + summary: Finds Pets by status + description: Multiple status values can be provided with comma seperated strings + operationId: findPetsByStatus + produces: + - application/xml + - application/json + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + collectionFormat: csv + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/Pet' + '400': + description: Invalid status value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + - Pagination + - JSONP + summary: Finds Pets by tags + description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.' + operationId: findPetsByTags + produces: + - application/xml + - application/json + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + type: array + items: + type: string + collectionFormat: csv + responses: + '200': + description: successful operation + schema: + type: array + items: + $ref: '#/definitions/Pet' + '400': + description: Invalid tag value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + /store/inventory: + get: + tags: + - store + - JSONP + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + produces: + - application/json + parameters: [] + responses: + '200': + description: successful operation + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: order placed for purchasing the pet + required: true + schema: + $ref: '#/definitions/Order' + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Order' + '400': + description: Invalid Order + '/store/order/{orderId}': + get: + tags: + - store + - JSONP + summary: Find purchase order by ID + description: 'For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions' + operationId: getOrderById + produces: + - application/xml + - application/json + parameters: + - name: orderId + in: path + description: ID of pet that needs to be fetched + required: true + type: integer + maximum: 5 + minimum: 1 + format: int64 + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + operationId: deleteOrder + produces: + - application/xml + - application/json + parameters: + - name: orderId + in: path + description: ID of the order that needs to be deleted + required: true + type: string + minimum: 1 + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: Created user object + required: true + schema: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + - JSONP + summary: Get user by user name + description: '' + operationId: getUserByName + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: 'The name that needs to be fetched. Use user1 for testing. ' + required: true + type: string + responses: + '200': + description: successful operation + schema: + $ref: '#/definitions/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + type: string + - in: body + name: body + description: Updated user object + required: true + schema: + $ref: '#/definitions/User' + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: List of user object + required: true + schema: + type: array + items: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + produces: + - application/xml + - application/json + parameters: + - in: body + name: body + description: List of user object + required: true + schema: + type: array + items: + $ref: '#/definitions/User' + responses: + default: + description: successful operation + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + produces: + - application/xml + - application/json + parameters: + - name: username + in: query + description: The user name for login + required: true + type: string + - name: password + in: query + description: The password for login in clear text + required: true + type: string + responses: + '200': + description: successful operation + schema: + type: string + headers: + X-Rate-Limit: + type: integer + format: int32 + description: calls per hour allowed by the user + X-Expires-After: + type: string + format: date-time + description: date in UTC when toekn expires + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + produces: + - application/xml + - application/json + parameters: [] + responses: + default: + description: successful operation +definitions: + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Cat: + description: A representation of a cat + allOf: + - $ref: '#/definitions/Pet' + - type: object + properties: + huntingSkill: + type: string + description: The measured skill for hunting + default: lazy + enum: + - clueless + - lazy + - adventurous + - aggressive + required: + - huntingSkill + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Category + Dog: + description: A representation of a dog + allOf: + - $ref: '#/definitions/Pet' + - type: object + properties: + packSize: + type: integer + format: int32 + description: the size of the pack the dog is from + default: 0 + minimum: 0 + required: + - packSize + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Pet: + type: object + required: + - name + - photoUrls + discriminator: petType + properties: + petType: + type: string + id: + type: integer + format: int64 + category: + $ref: '#/definitions/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/definitions/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + User: + type: object + properties: + id: + type: integer + format: int64 + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.ts similarity index 58% rename from lib/components/ApiInfo/api-info.js rename to lib/components/ApiInfo/api-info.ts index 89d39f6d..7c9e697b 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.ts @@ -5,16 +5,16 @@ import { OptionsService } from '../../services/index'; @RedocComponent({ selector: 'api-info', - styleUrls: ['./lib/components/ApiInfo/api-info.css'], - templateUrl: './lib/components/ApiInfo/api-info.html' + styleUrls: ['./api-info.css'], + templateUrl: './api-info.html' }) -@Reflect.metadata('parameters', [[SchemaManager], [OptionsService]]) export class ApiInfo extends BaseComponent { - constructor(schemaMgr, optionsService) { + data: any; + specUrl: String; + constructor(schemaMgr:SchemaManager, private optionsService:OptionsService) { super(schemaMgr); - this.optionsService = optionsService; } - + prepareModel() { this.data = this.componentSchema.info; this.specUrl = this.optionsService.options.specUrl; diff --git a/lib/components/ApiLogo/api-logo.js b/lib/components/ApiLogo/api-logo.ts similarity index 61% rename from lib/components/ApiLogo/api-logo.js rename to lib/components/ApiLogo/api-logo.ts index dcf5a0bc..8a50e834 100644 --- a/lib/components/ApiLogo/api-logo.js +++ b/lib/components/ApiLogo/api-logo.ts @@ -1,19 +1,20 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; +import {RedocComponent, BaseComponent, SchemaManager} from '../base'; @RedocComponent({ selector: 'api-logo', - styleUrls: ['./lib/components/ApiLogo/api-logo.css'], - templateUrl: './lib/components/ApiLogo/api-logo.html' + styleUrls: ['./api-logo.css'], + templateUrl: './api-logo.html' }) export class ApiLogo extends BaseComponent { - constructor(schemaMgr) { + data:any = {}; + + constructor(schemaMgr:SchemaManager) { super(schemaMgr); } prepareModel() { - this.data = {}; let logoInfo = this.componentSchema.info['x-logo']; if (!logoInfo) return; this.data.imgUrl = logoInfo.url; diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.ts similarity index 73% rename from lib/components/JsonSchema/json-schema-lazy.js rename to lib/components/JsonSchema/json-schema-lazy.ts index 209180d3..07bbef95 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.ts @@ -2,11 +2,11 @@ import { Component, ElementRef, ViewContainerRef } from '@angular/core'; import { CORE_DIRECTIVES } from '@angular/common'; -import { DynamicComponentLoader } from '@angular/core'; +import { DynamicComponentLoader, Input } from '@angular/core'; import { JsonSchema } from './json-schema'; -import { OptionsService } from '../../services/index'; -import SchemaManager from '../../utils/SchemaManager'; +import { OptionsService } from '../../services/options.service'; +import { SchemaManager } from '../../utils/SchemaManager'; var cache = {}; @@ -14,20 +14,16 @@ var cache = {}; @Component({ selector: 'json-schema-lazy', - inputs: ['pointer', 'auto', 'isRequestSchema'], template: '', directives: [CORE_DIRECTIVES] }) -@Reflect.metadata('parameters', [[SchemaManager], [ViewContainerRef], [ - ElementRef], [DynamicComponentLoader], [OptionsService]]) export class JsonSchemaLazy { - - constructor(schemaMgr, viewRef, elementRef, dcl, optionsService) { - this.viewRef = viewRef; - this.elementRef = elementRef; - this.dcl = dcl; - this.optionsService = optionsService; - this.schemaMgr = schemaMgr; + @Input() pointer: string; + @Input() auto: boolean; + @Input() isRequestSchema: boolean; + loaded: boolean = false; + constructor(private schemaMgr:SchemaManager, private viewRef:ViewContainerRef, private elementRef:ElementRef, + private dcl:DynamicComponentLoader, private optionsService:OptionsService) { } normalizePointer() { @@ -40,8 +36,6 @@ export class JsonSchemaLazy { this.initComponent(compRef); if (compRef.changeDetectorRef) { compRef.changeDetectorRef.detectChanges(); - } else { - compRef.hostView.changeDetectorRef.detectChanges(); } return compRef; }); @@ -58,7 +52,7 @@ export class JsonSchemaLazy { // cache JsonSchema view loadCached() { - this.pointer = this.normalizePointer(this.pointer); + this.pointer = this.normalizePointer(); if (cache[this.pointer]) { cache[this.pointer].then((compRef) => { setTimeout( ()=> { diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.ts similarity index 95% rename from lib/components/JsonSchema/json-schema.js rename to lib/components/JsonSchema/json-schema.ts index c313c350..929b3e24 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.ts @@ -1,6 +1,6 @@ 'use strict'; -import { ElementRef } from '@angular/core'; +import { ElementRef, Input } from '@angular/core'; import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { DropDown } from '../../shared/components/index'; @@ -8,18 +8,24 @@ import JsonPointer from '../../utils/JsonPointer'; @RedocComponent({ selector: 'json-schema', - templateUrl: './lib/components/JsonSchema/json-schema.html', - styleUrls: ['./lib/components/JsonSchema/json-schema.css'], + templateUrl: './json-schema.html', + styleUrls: ['./json-schema.css'], directives: [JsonSchema, DropDown], - inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'isRequestSchema'], detect: true }) -@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) export class JsonSchema extends BaseComponent { - constructor(schemaMgr, elementRef) { + $element: any; + schema: any; + derivedEmtpy: boolean; + @Input() isArray: boolean; + @Input() final: boolean = false; + @Input() nestOdd: boolean; + @Input() childFor: string; + @Input() isRequestSchema: boolean; + + constructor(schemaMgr:SchemaManager, elementRef:ElementRef) { super(schemaMgr); this.$element = elementRef.nativeElement; - this.final = false; } selectDerived(subClassIdx) { @@ -132,7 +138,7 @@ export class JsonSchema extends BaseComponent { JsonPointer.join(addProps._pointer || schema._pointer || this.pointer, ['additionalProperties'])); } - static injectPropertyData(propertySchema, propertyName, propPointer, hostPointer) { + static injectPropertyData(propertySchema, propertyName, propPointer, hostPointer?) { propertySchema = Object.assign({}, propertySchema); propertySchema._name = propertyName; @@ -142,7 +148,7 @@ export class JsonSchema extends BaseComponent { } } -function runInjectors(injectTo, propertySchema, propertyPointer, hostPointer) { +function runInjectors(injectTo, propertySchema, propertyPointer, hostPointer?) { for (var injName in injectors) { let injector = injectors[injName]; if (injector.check(propertySchema)) { diff --git a/lib/components/Method/method.js b/lib/components/Method/method.ts similarity index 83% rename from lib/components/Method/method.js rename to lib/components/Method/method.ts index 9b2ce7fa..04c85077 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.ts @@ -1,7 +1,7 @@ 'use strict'; - -import { JsonPointer } from '../../utils/JsonPointer'; -import { RedocComponent, BaseComponent } from '../base'; +import { Input } from '@angular/core'; +import JsonPointer from '../../utils/JsonPointer'; +import { RedocComponent, BaseComponent, SchemaManager} from '../base'; import { ParamsList } from '../ParamsList/params-list'; import { ResponsesList } from '../ResponsesList/responses-list'; @@ -11,14 +11,15 @@ import { RequestSamples } from '../RequestSamples/request-samples'; @RedocComponent({ selector: 'method', - templateUrl: './lib/components/Method/method.html', - styleUrls: ['./lib/components/Method/method.css'], + templateUrl: './method.html', + styleUrls: ['./method.css'], directives: [ ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples ], - inputs: ['tag'], detect: true }) export class Method extends BaseComponent { - constructor(schemaMgr) { + data:any; + @Input() tag:string; + constructor(schemaMgr:SchemaManager) { super(schemaMgr); } diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.ts similarity index 79% rename from lib/components/MethodsList/methods-list.js rename to lib/components/MethodsList/methods-list.ts index 3c036b99..fe80c592 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.ts @@ -1,21 +1,21 @@ 'use strict'; import { forwardRef } from '@angular/core'; -import { RedocComponent, BaseComponent } from '../base'; +import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { Method } from '../Method/method'; import { EncodeURIComponentPipe } from '../../utils/pipes'; @RedocComponent({ selector: 'methods-list', - templateUrl: './lib/components/MethodsList/methods-list.html', - styleUrls: ['./lib/components/MethodsList/methods-list.css'], + templateUrl: './methods-list.html', + styleUrls: ['./methods-list.css'], directives: [ forwardRef(() => Method) ], pipes: [ EncodeURIComponentPipe ], detect: true }) export class MethodsList extends BaseComponent { - - constructor(schemaMgr) { + data:any; + constructor(schemaMgr:SchemaManager) { super(schemaMgr); } @@ -25,7 +25,7 @@ export class MethodsList extends BaseComponent { // duplicate methods let menuStructure = this.schemaMgr.buildMenuTree(); - let tags = Array.from(menuStructure.entries()) + let tags = Array.from(menuStructure.entries()) .map((entry) => { let [tag, {description, methods}] = entry; // inject tag name into method info diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.ts similarity index 90% rename from lib/components/ParamsList/params-list.js rename to lib/components/ParamsList/params-list.ts index 99b147c2..c4f2d285 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.ts @@ -1,6 +1,6 @@ 'use strict'; -import { RedocComponent, BaseComponent } from '../base'; +import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { JsonSchema } from '../JsonSchema/json-schema'; import {JsonSchemaLazy} from '../JsonSchema/json-schema-lazy'; @@ -11,12 +11,15 @@ function safePush(obj, prop, item) { @RedocComponent({ selector: 'params-list', - templateUrl: './lib/components/ParamsList/params-list.html', - styleUrls: ['./lib/components/ParamsList/params-list.css'], + templateUrl: './params-list.html', + styleUrls: ['./params-list.css'], directives: [JsonSchema, JsonSchemaLazy] }) export class ParamsList extends BaseComponent { - constructor(schemaMgr) { + + data:any; + + constructor(schemaMgr:SchemaManager) { super(schemaMgr); } @@ -62,7 +65,7 @@ export class ParamsList extends BaseComponent { this.data.params = params; } - orderParams(params) { + orderParams(params):any { let res = {}; params.forEach((param) => safePush(res, param.in, param)); return res; diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.ts similarity index 85% rename from lib/components/Redoc/redoc.js rename to lib/components/Redoc/redoc.ts index 456d1c18..9df657fe 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.ts @@ -1,6 +1,6 @@ 'use strict'; -import { provide, enableProdMode, ElementRef } from '@angular/core'; +import { provide, enableProdMode, ElementRef, ComponentRef } from '@angular/core'; import { bootstrap } from '@angular/platform-browser-dynamic'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { RedocComponent, BaseComponent } from '../base'; @@ -13,12 +13,12 @@ import { MethodsList } from '../MethodsList/methods-list'; import { SideMenu } from '../SideMenu/side-menu'; import { StickySidebar } from '../../shared/components/index'; -import SchemaManager from '../../utils/SchemaManager'; +import {SchemaManager} from '../../utils/SchemaManager'; import { OptionsService, RedocEventsService } from '../../services/index'; -import redocVersion from '../../version.json!json'; +//import redocVersion from '../../version.js'; -import './redoc-initial-styles.css!css'; +//import './redoc-initial-styles.css!css'; var dom = new BrowserDomAdapter(); var _modeLocked = false; @@ -30,16 +30,19 @@ var _modeLocked = false; BrowserDomAdapter, RedocEventsService ], - templateUrl: './lib/components/Redoc/redoc.html', - styleUrls: ['./lib/components/Redoc/redoc.css'], + templateUrl: './redoc.html', + styleUrls: ['./redoc.css'], directives: [ ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar ], detect: true, onPushOnly: false }) -@Reflect.metadata('parameters', [ - [SchemaManager], [OptionsService], [ElementRef], [RedocEventsService]]) export class Redoc extends BaseComponent { - constructor(schemaMgr, optionsMgr, elementRef, events) { + private element: any; + options: any; + static appRef: ComponentRef; + + constructor(schemaMgr: SchemaManager, optionsMgr:OptionsService, elementRef:ElementRef, + public events:RedocEventsService) { super(schemaMgr); this.element = elementRef.nativeElement; //parse options (top level component doesn't support inputs) @@ -51,7 +54,7 @@ export class Redoc extends BaseComponent { ngAfterViewInit() { setTimeout( () => { - this.events.bootstrapped.next(); + this.events.bootstrapped.next({}); }); } @@ -69,7 +72,7 @@ export class Redoc extends BaseComponent { }, 400); } - static init(specUrl, options) { + static init(specUrl, options?) { var optionsService = new OptionsService(dom); optionsService.options = options; optionsService.options.specUrl = optionsService.options.specUrl || specUrl; @@ -121,9 +124,9 @@ export class Redoc extends BaseComponent { redocEl.innerHTML = erroHtml; } - static get version() { - return redocVersion; - } + // static get version() { + // return redocVersion; + // } static destroy() { let el = dom.query('redoc'); diff --git a/lib/components/RequestSamples/request-samples.js b/lib/components/RequestSamples/request-samples.ts similarity index 67% rename from lib/components/RequestSamples/request-samples.js rename to lib/components/RequestSamples/request-samples.ts index f31de1ac..5efb66ad 100644 --- a/lib/components/RequestSamples/request-samples.js +++ b/lib/components/RequestSamples/request-samples.ts @@ -1,6 +1,6 @@ 'use strict'; -import { ViewChildren, QueryList } from '@angular/core'; +import { ViewChildren, QueryList, EventEmitter, Input} from '@angular/core'; import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import JsonPointer from '../../utils/JsonPointer'; @@ -11,22 +11,25 @@ import { RedocEventsService } from '../../services/index'; @RedocComponent({ selector: 'request-samples', - templateUrl: './lib/components/RequestSamples/request-samples.html', - styleUrls: ['./lib/components/RequestSamples/request-samples.css'], + templateUrl: './request-samples.html', + styleUrls: ['./request-samples.css'], directives: [SchemaSample, Tabs, Tab], inputs: ['schemaPointer'], pipes: [PrismPipe], detect: true, onPushOnly: false }) -@Reflect.metadata('parameters', [[SchemaManager], [RedocEventsService], [new ViewChildren(Tabs), QueryList]]) export class RequestSamples extends BaseComponent { - constructor(schemaMgr, events, childQuery) { + childTabs: Tabs; + selectedLang: EventEmitter; + data: any; + @Input() schemaPointer:string; + @ViewChildren(Tabs) childQuery:QueryList; + constructor(schemaMgr:SchemaManager, public events:RedocEventsService) { super(schemaMgr); - childQuery.changes.subscribe(() => { - this.childTabs = childQuery.first; + this.childQuery.changes.subscribe(() => { + this.childTabs = this.childQuery.first; }); - this.events = events; this.selectedLang = this.events.samplesLanguageChanged; } diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.ts similarity index 87% rename from lib/components/ResponsesList/responses-list.js rename to lib/components/ResponsesList/responses-list.ts index 473fae84..aa80497c 100644 --- a/lib/components/ResponsesList/responses-list.js +++ b/lib/components/ResponsesList/responses-list.ts @@ -14,14 +14,15 @@ function isNumeric(n) { @RedocComponent({ selector: 'responses-list', - templateUrl: './lib/components/ResponsesList/responses-list.html', - styleUrls: ['./lib/components/ResponsesList/responses-list.css'], + templateUrl: './responses-list.html', + styleUrls: ['./responses-list.css'], directives: [JsonSchema, Zippy, JsonSchemaLazy], detect: true }) -@Reflect.metadata('parameters', [[SchemaManager], [OptionsService]]) export class ResponsesList extends BaseComponent { - constructor(schemaMgr, optionsMgr) { + data: any; + options: any; + constructor(schemaMgr:SchemaManager, optionsMgr:OptionsService) { super(schemaMgr); this.options = optionsMgr.options; } diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.ts similarity index 85% rename from lib/components/ResponsesSamples/responses-samples.js rename to lib/components/ResponsesSamples/responses-samples.ts index 3515f5e9..ab1d0827 100644 --- a/lib/components/ResponsesSamples/responses-samples.js +++ b/lib/components/ResponsesSamples/responses-samples.ts @@ -1,7 +1,7 @@ 'use strict'; import { forwardRef } from '@angular/core'; -import { RedocComponent, BaseComponent } from '../base'; +import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import JsonPointer from '../../utils/JsonPointer'; import { Tabs, Tab } from '../../shared/components/index'; import { SchemaSample } from '../index'; @@ -19,12 +19,13 @@ function hasExample(response) { @RedocComponent({ selector: 'responses-samples', - templateUrl: './lib/components/ResponsesSamples/responses-samples.html', - styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'], + templateUrl: './responses-samples.html', + styleUrls: ['./responses-samples.css'], directives: [forwardRef( ()=> SchemaSample), Tabs, Tab] }) export class ResponsesSamples extends BaseComponent { - constructor(schemaMgr) { + data: any; + constructor(schemaMgr:SchemaManager) { super(schemaMgr); } diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.ts similarity index 85% rename from lib/components/SchemaSample/schema-sample.js rename to lib/components/SchemaSample/schema-sample.ts index 0c350ba1..d9d6dedc 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.ts @@ -9,13 +9,14 @@ import { JsonFormatter } from '../../utils/JsonFormatterPipe'; @RedocComponent({ selector: 'schema-sample', - templateUrl: './lib/components/SchemaSample/schema-sample.html', + templateUrl: './schema-sample.html', pipes: [JsonFormatter], - styleUrls: ['./lib/components/SchemaSample/schema-sample.css'] + styleUrls: ['./schema-sample.css'] }) -@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) export class SchemaSample extends BaseComponent { - constructor(schemaMgr, elementRef) { + element: any; + data: any; + constructor(schemaMgr:SchemaManager, elementRef:ElementRef) { super(schemaMgr); this.element = elementRef.nativeElement; } @@ -23,7 +24,7 @@ export class SchemaSample extends BaseComponent { init() { this.data = {}; - let base = {}; + let base:any = {}; let sample; // got pointer not directly to the schema but e.g. to response obj diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.ts similarity index 82% rename from lib/components/SideMenu/side-menu.js rename to lib/components/SideMenu/side-menu.ts index 9834f61b..9e1b8475 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.ts @@ -9,29 +9,31 @@ import { ScrollService, Hash, MenuService, OptionsService } from '../../services @RedocComponent({ selector: 'side-menu', - templateUrl: './lib/components/SideMenu/side-menu.html', + templateUrl: './side-menu.html', providers: [ScrollService, MenuService, Hash], - styleUrls: ['./lib/components/SideMenu/side-menu.css'], + styleUrls: ['./side-menu.css'], detect: true, onPushOnly: false }) -@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], [BrowserDomAdapter], - [ScrollService], [MenuService], [Hash], [OptionsService], [ChangeDetectorRef]]) export class SideMenu extends BaseComponent { - constructor(schemaMgr, elementRef, dom, scrollService, - menuService, hash, optionsService, detectorRef) { + $element: any; + $mobileNav: any; + $resourcesNav: any; + $scrollParent: any; + activeCatCaption: string; + activeItemCaption: string; + options: any; + data: any; + constructor(schemaMgr:SchemaManager, elementRef:ElementRef, private dom:BrowserDomAdapter, + private scrollService:ScrollService, private menuService:MenuService, private hash:Hash, + optionsService:OptionsService, private detectorRef:ChangeDetectorRef) { super(schemaMgr); this.$element = elementRef.nativeElement; - this.dom = dom; - this.scrollService = scrollService; - this.menuService = menuService; - this.hash = hash; this.activeCatCaption = ''; this.activeItemCaption = ''; this.options = optionsService.options; - this.detectorRef = detectorRef; this.menuService.changed.subscribe((evt) => this.changed(evt)); } diff --git a/lib/components/base.js b/lib/components/base.ts similarity index 97% rename from lib/components/base.js rename to lib/components/base.ts index 38bd2b57..b30af2ed 100644 --- a/lib/components/base.js +++ b/lib/components/base.ts @@ -1,7 +1,7 @@ 'use strict'; import { Component, ChangeDetectionStrategy } from '@angular/core'; import { CORE_DIRECTIVES, JsonPipe, AsyncPipe } from '@angular/common'; -import SchemaManager from '../utils/SchemaManager'; +import { SchemaManager } from '../utils/SchemaManager'; import JsonPointer from '../utils/JsonPointer'; import { MarkedPipe, JsonPointerEscapePipe } from '../utils/pipes'; @@ -94,10 +94,10 @@ export function RedocComponent(options) { * Generic Component * @class */ -@Reflect.metadata('parameters', [[SchemaManager]]) export class BaseComponent { - constructor(schemaMgr) { - this.schemaMgr = schemaMgr; + componentSchema: any; + pointer: String; + constructor(public schemaMgr: SchemaManager) { this.componentSchema = null; } @@ -166,7 +166,7 @@ export class BaseComponent { return schema; }; - this.componentSchema = snapshot(resolve(schema, 1)); + this.componentSchema = snapshot(resolve(schema)); } static joinAllOf(schema, opts) { diff --git a/lib/components/index.js b/lib/components/index.ts similarity index 100% rename from lib/components/index.js rename to lib/components/index.ts diff --git a/lib/index.js b/lib/index.ts similarity index 80% rename from lib/index.js rename to lib/index.ts index 1a0b8775..47ca1293 100644 --- a/lib/index.js +++ b/lib/index.ts @@ -3,5 +3,5 @@ import {Redoc} from './components/index'; export var init = Redoc.init; -window.Redoc = Redoc; +window['Redoc'] = Redoc; Redoc.autoInit(); diff --git a/lib/services/events.service.js b/lib/services/events.service.js deleted file mode 100644 index 57cf41f9..00000000 --- a/lib/services/events.service.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -import { EventEmitter } from '@angular/core'; - -export class RedocEventsService { - constructor() { - this.bootstrapped = new EventEmitter(); - this.samplesLanguageChanged = new EventEmitter(); - } -} diff --git a/lib/services/events.service.ts b/lib/services/events.service.ts new file mode 100644 index 00000000..0bc86e1d --- /dev/null +++ b/lib/services/events.service.ts @@ -0,0 +1,8 @@ +'use strict'; + +import { EventEmitter, Output } from '@angular/core'; + +export class RedocEventsService { + @Output() bootstrapped = new EventEmitter(); + @Output() samplesLanguageChanged = new EventEmitter(); +} diff --git a/lib/services/hash.service.spec.js b/lib/services/hash.service.spec.js index 80fba625..9086ab32 100644 --- a/lib/services/hash.service.spec.js +++ b/lib/services/hash.service.spec.js @@ -19,7 +19,7 @@ describe('Hash Service', () => { it('should trigger changed event after ReDoc bootstrapped', (done) => { spyOn(hashService.changed, 'next').and.callThrough(); - events.bootstrapped.next(); + events.bootstrapped.next({}); setTimeout(() => { expect(hashService.changed.next).toHaveBeenCalled(); done(); diff --git a/lib/services/hash.service.js b/lib/services/hash.service.ts similarity index 73% rename from lib/services/hash.service.js rename to lib/services/hash.service.ts index 588df861..a61fc392 100644 --- a/lib/services/hash.service.js +++ b/lib/services/hash.service.ts @@ -1,16 +1,15 @@ 'use strict'; -import { Injectable, EventEmitter } from '@angular/core'; +import { Injectable, EventEmitter, Output } from '@angular/core'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { global } from '@angular/core/src/facade/lang'; import { RedocEventsService } from './events.service'; -@Reflect.metadata('parameters', [[BrowserDomAdapter], [RedocEventsService]]) @Injectable() export class Hash { - constructor(dom, events) { - this.changed = new EventEmitter(); - this.dom = dom; + @Output() changed = new EventEmitter(); + private _cancel: any; + constructor(private dom:BrowserDomAdapter, private events:RedocEventsService) { this.bind(); events.bootstrapped.subscribe(() => this.changed.next(this.hash)); diff --git a/lib/services/index.js b/lib/services/index.js deleted file mode 100644 index c9962f48..00000000 --- a/lib/services/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -export * from './events.service.js'; -export * from './options.service.js'; -export * from './menu.service.js'; -export * from './scroll.service.js'; -export * from './hash.service.js'; diff --git a/lib/services/index.ts b/lib/services/index.ts new file mode 100644 index 00000000..fed26281 --- /dev/null +++ b/lib/services/index.ts @@ -0,0 +1,7 @@ +'use strict'; + +export * from './events.service'; +export * from './options.service'; +export * from './menu.service'; +export * from './scroll.service'; +export * from './hash.service'; diff --git a/lib/services/menu.service.js b/lib/services/menu.service.ts similarity index 91% rename from lib/services/menu.service.js rename to lib/services/menu.service.ts index 5c2ea128..b6bfca21 100644 --- a/lib/services/menu.service.js +++ b/lib/services/menu.service.ts @@ -1,8 +1,8 @@ 'use strict'; import { Injectable, EventEmitter } from '@angular/core'; -import { ScrollService, INVIEW_POSITION } from './scroll.service.js'; -import { Hash } from './hash.service.js'; -import SchemaManager from '../utils/SchemaManager'; +import { ScrollService, INVIEW_POSITION } from './scroll.service'; +import { Hash } from './hash.service'; +import { SchemaManager } from '../utils/SchemaManager'; const CHANGE = { NEXT : 1, @@ -10,16 +10,17 @@ const CHANGE = { INITIAL : 0 }; -@Reflect.metadata('parameters', [[Hash], [ScrollService], [SchemaManager]]) @Injectable() export class MenuService { - constructor(hash, scrollService, schemaMgr) { - this.hash = hash; - this.scrollService = scrollService; + changed: EventEmitter = new EventEmitter(); + categories: any; + + activeCatIdx: number = 0; + activeMethodIdx: number = -1; + activeMethodPtr: string; - this.activeCatIdx = 0; - this.activeMethodIdx = -1; - this.changed = new EventEmitter(); + constructor(private hash:Hash, private scrollService:ScrollService, schemaMgr:SchemaManager) { + this.hash = hash; this.categories = Array.from(schemaMgr.buildMenuTree().entries()).map( el => ({name: el[0], description: el[1].description, methods: el[1].methods}) diff --git a/lib/services/options.service.js b/lib/services/options.service.ts similarity index 94% rename from lib/services/options.service.js rename to lib/services/options.service.ts index 71288bba..4a2c0fe4 100644 --- a/lib/services/options.service.js +++ b/lib/services/options.service.ts @@ -7,15 +7,16 @@ import { global } from '@angular/core/src/facade/lang'; const defaults = { scrollYOffset: 0, disableLazySchemas: false, - debugMode: global && global.redocDebugMode + debugMode: false//global && global.redocDebugMode }; const OPTION_NAMES = new Set(['scrollYOffset', 'disableLazySchemas', 'specUrl']); @Injectable() -@Reflect.metadata('parameters', [[BrowserDomAdapter]]) export class OptionsService { - constructor(dom) { + private _options: any; + + constructor(private dom:BrowserDomAdapter) { this._options = defaults; this.dom = dom; } diff --git a/lib/services/scroll.service.js b/lib/services/scroll.service.ts similarity index 84% rename from lib/services/scroll.service.js rename to lib/services/scroll.service.ts index 6daa83fb..7c767d2b 100644 --- a/lib/services/scroll.service.js +++ b/lib/services/scroll.service.ts @@ -1,7 +1,7 @@ 'use strict'; -import { Injectable, EventEmitter } from '@angular/core'; +import { Injectable, EventEmitter, Output } from '@angular/core'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; -import { OptionsService } from './options.service.js'; +import { OptionsService } from './options.service'; export const INVIEW_POSITION = { ABOVE : 1, @@ -9,11 +9,14 @@ export const INVIEW_POSITION = { INVIEW: 0 }; -@Reflect.metadata('parameters', [ - [BrowserDomAdapter], [OptionsService]]) @Injectable() export class ScrollService { - constructor(dom, optionsService) { + scrollYOffset: any; + $scrollParent: any; + @Output() scroll = new EventEmitter(); + private prevOffsetY: number; + private _cancel:any; + constructor(private dom:BrowserDomAdapter, optionsService:OptionsService) { //events.bootstrapped.subscribe(() => this.hashScroll()); this.scrollYOffset = () => optionsService.options.scrollYOffset(); this.$scrollParent = optionsService.options.$scrollParent; diff --git a/lib/shared/components/DropDown/drop-down.css.shim.ts b/lib/shared/components/DropDown/drop-down.css.shim.ts new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/DropDown/drop-down.js b/lib/shared/components/DropDown/drop-down.ts similarity index 50% rename from lib/shared/components/DropDown/drop-down.js rename to lib/shared/components/DropDown/drop-down.ts index 349dd0a3..4798a3fe 100644 --- a/lib/shared/components/DropDown/drop-down.js +++ b/lib/shared/components/DropDown/drop-down.ts @@ -1,30 +1,30 @@ 'use strict'; -import {Component, EventEmitter, ElementRef} from '@angular/core'; +import {Component, EventEmitter, ElementRef, Output} from '@angular/core'; import {CORE_DIRECTIVES} from '@angular/common'; -import DropKick from 'Robdel12/DropKick'; -import 'Robdel12/DropKick/build/css/dropkick.css!css'; +import DropKick from 'dropkickjs'; +//import 'Robdel12/DropKick/build/css/dropkick.css!css'; @Component({ selector: 'dropdown', - events: ['change'], template: ` `, directives: [CORE_DIRECTIVES], - styleUrls: ['./lib/shared/components/DropDown/drop-down.css'] + styleUrls: ['./drop-down.css'] }) -@Reflect.metadata('parameters', [[ElementRef]]) export class DropDown { - constructor(elem) { - this.change = new EventEmitter(); + @Output() change = new EventEmitter(); + elem: any; + inst: any; + constructor(elem:ElementRef) { this.elem = elem.nativeElement; } ngAfterContentInit() { - this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true}); + //this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true}); } onChange(value) { diff --git a/lib/shared/components/StickySidebar/sticky-sidebar.js b/lib/shared/components/StickySidebar/sticky-sidebar.ts similarity index 78% rename from lib/shared/components/StickySidebar/sticky-sidebar.js rename to lib/shared/components/StickySidebar/sticky-sidebar.ts index 6aa8a274..96149a72 100644 --- a/lib/shared/components/StickySidebar/sticky-sidebar.js +++ b/lib/shared/components/StickySidebar/sticky-sidebar.ts @@ -1,17 +1,21 @@ 'use strict'; -import {Directive, ElementRef} from '@angular/core'; +import {Directive, ElementRef, Input} from '@angular/core'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; @Directive({ selector: '[sticky-sidebar]', inputs: ['scrollParent', 'scrollYOffset'] }) -@Reflect.metadata('parameters', [[ElementRef], [BrowserDomAdapter]]) export class StickySidebar { - constructor(elementRef, dom) { + $element: any; + cancelScrollBinding: any; + $redocEl: any; + @Input() scrollParent:any; + @Input() scrollYOffset:any; + + constructor(elementRef:ElementRef, private dom:BrowserDomAdapter) { this.$element = elementRef.nativeElement; - this.dom = dom; // initial styling this.dom.setStyle(this.$element, 'position', 'absolute'); @@ -44,7 +48,7 @@ export class StickySidebar { unstick() { this.dom.setStyle(this.$element, 'position', 'absolute'); - this.dom.setStyle(this.$element, 'top', 0); + this.dom.setStyle(this.$element, 'top', '0'); } get scrollY() { @@ -53,7 +57,7 @@ export class StickySidebar { ngOnInit() { // FIXME use more reliable code - this.$redocEl = this.$element.offsetParent; + this.$redocEl = this.$element.offsetParent || this.dom.defaultDoc().body; this.bind(); } diff --git a/lib/shared/components/Tabs/tabs.js b/lib/shared/components/Tabs/tabs.ts similarity index 78% rename from lib/shared/components/Tabs/tabs.js rename to lib/shared/components/Tabs/tabs.ts index 5cf174ec..ede596b4 100644 --- a/lib/shared/components/Tabs/tabs.js +++ b/lib/shared/components/Tabs/tabs.ts @@ -1,13 +1,11 @@ 'use strict'; -import { Component, EventEmitter } from '@angular/core'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; import { CORE_DIRECTIVES } from '@angular/common'; import { ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core'; @Component({ selector: 'tabs', - events: ['change'], - inputs: ['selected'], template: `
  • `, directives: [CORE_DIRECTIVES], - styleUrls: ['./lib/shared/components/Tabs/tabs.css'], + styleUrls: ['tabs.css'], changeDetection: ChangeDetectionStrategy.OnPush }) -@Reflect.metadata('parameters', [[ChangeDetectorRef]]) export class Tabs { - constructor(changeDetector) { - this.tabs = []; - this.change = new EventEmitter(); - this.changeDetector = changeDetector; - } + @Input() selected: any; + @Output() change = new EventEmitter(); + tabs: Tab[] = []; + constructor(private changeDetector:ChangeDetectorRef) {} selectTab(tab, notify = true) { if (tab.active) return; @@ -69,7 +65,6 @@ export class Tabs { @Component({ selector: 'tab', - inputs: ['tabTitle', 'tabStatus'], template: `
    @@ -86,10 +81,11 @@ export class Tabs { }` ] }) -@Reflect.metadata('parameters', [ [Tabs] ]) export class Tab { - constructor(tabs) { - this.active = false; + @Input() active: boolean = false; + @Input() tabTitle: string; + @Input() tabStatus: string; + constructor(tabs: Tabs) { tabs.addTab(this); } } diff --git a/lib/shared/components/Zippy/zippy.css.shim.ts b/lib/shared/components/Zippy/zippy.css.shim.ts new file mode 100644 index 00000000..27451d96 --- /dev/null +++ b/lib/shared/components/Zippy/zippy.css.shim.ts @@ -0,0 +1,5 @@ +/** + * This file is generated by the Angular 2 template compiler. + * Do not edit. + */ +export const styles:any[] = ['.zippy-title[_ngcontent-%COMP%]{padding:10px;border-radius:2px;margin:2px 0;line-height:1.5em;background-color:#f2f2f2;cursor:pointer}.zippy-success[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#00aa13;background-color:rgba(0,170,19,0.08)}.zippy-error[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#e53935;background-color:rgba(229,57,53,0.06)}.zippy-redirect[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#263238;background-color:rgba(38,50,56,0.08)}.zippy-info[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#0033a0;background-color:rgba(0,51,160,0.08)}span.zippy-indicator[_ngcontent-%COMP%]{font-size:1.2em;margin-right:0.2em;position:relative;top:0}.zippy-content[_ngcontent-%COMP%]{padding:15px 0}.zippy-empty[_ngcontent-%COMP%] .zippy-title[_ngcontent-%COMP%]{cursor:default}.zippy-empty[_ngcontent-%COMP%] .zippy-indicator[_ngcontent-%COMP%]{display:none}.zippy-empty[_ngcontent-%COMP%] .zippy-content[_ngcontent-%COMP%]{display:none}.zippy-hidden[_ngcontent-%COMP%]{overflow:hidden;visibility:hidden;height:0;padding:0}']; \ No newline at end of file diff --git a/lib/shared/components/Zippy/zippy.js b/lib/shared/components/Zippy/zippy.js deleted file mode 100644 index 9fdc2a65..00000000 --- a/lib/shared/components/Zippy/zippy.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -import {Component, EventEmitter} from '@angular/core'; -import {CORE_DIRECTIVES} from '@angular/common'; - -@Component({ - selector: 'zippy', - events: ['open', 'close'], - inputs: ['title', 'visible', 'type', 'empty'], - templateUrl: './lib/shared/components/Zippy/zippy.html', - styleUrls: ['./lib/shared/components/Zippy/zippy.css'], - directives: [CORE_DIRECTIVES] -}) -export class Zippy { - - constructor() { - this.type = 'general'; - this.visible = false; - this.empty = false; - this.open = new EventEmitter(); - this.close = new EventEmitter(); - } - - toggle() { - this.visible = !this.visible; - if (this.empty) return; - (this.visible) ? this.open.next() : this.close.next(); - } -} diff --git a/lib/shared/components/Zippy/zippy.ts b/lib/shared/components/Zippy/zippy.ts new file mode 100644 index 00000000..95976f82 --- /dev/null +++ b/lib/shared/components/Zippy/zippy.ts @@ -0,0 +1,25 @@ +'use strict'; + +import {Component, EventEmitter, Output, Input} from '@angular/core'; +import {CORE_DIRECTIVES} from '@angular/common'; + +@Component({ + selector: 'zippy', + templateUrl: './zippy.html', + styleUrls: ['./zippy.css'], + directives: [CORE_DIRECTIVES] +}) +export class Zippy { + @Input() type = 'general'; + @Input() visible = false; + @Input() empty = false; + @Input() title; + @Output() open = new EventEmitter(); + @Output() close = new EventEmitter(); + + toggle() { + this.visible = !this.visible; + if (this.empty) return; + (this.visible) ? this.open.next({}) : this.close.next({}); + } +} diff --git a/lib/shared/components/index.js b/lib/shared/components/index.ts similarity index 100% rename from lib/shared/components/index.js rename to lib/shared/components/index.ts diff --git a/lib/utils/JsonFormatterPipe.js b/lib/utils/JsonFormatterPipe.ts similarity index 100% rename from lib/utils/JsonFormatterPipe.js rename to lib/utils/JsonFormatterPipe.ts diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.ts similarity index 77% rename from lib/utils/JsonPointer.js rename to lib/utils/JsonPointer.ts index 8dd8fc90..4138d8b7 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.ts @@ -1,10 +1,12 @@ 'use strict'; import JsonPointerLib from 'json-pointer'; +const origParse = JsonPointerLib.parse; /** * Wrapper for JsonPointer. Provides common operations */ -export class JsonPointer extends JsonPointerLib { + +class JsonPointer { /** * returns last JsonPointer token * if level > 1 returns levels last (second last/third last) @@ -30,7 +32,7 @@ export class JsonPointer extends JsonPointerLib { */ static dirName(pointer, level=1) { let tokens = JsonPointer.parse(pointer); - return JsonPointer.compile(tokens.slice(0, tokens.length - level)); + return JsonPointerLib.compile(tokens.slice(0, tokens.length - level)); } /** @@ -42,7 +44,7 @@ export class JsonPointer extends JsonPointerLib { if (ptr.charAt(0) === '#') { ptr = ptr.substring(1); } - return JsonPointerLib._origParse(ptr); + return origParse(ptr); } /** @@ -56,13 +58,21 @@ export class JsonPointer extends JsonPointerLib { // TODO: optimize let baseTokens = JsonPointer.parse(base); let resTokens = baseTokens.concat(tokens); - return JsonPointer.compile(resTokens); + return JsonPointerLib.compile(resTokens); + } + + static get(object: Object, pointer:string) { + return JsonPointerLib.get(object, pointer); + } + + static compile(tokens: string[]) { + return JsonPointerLib.compile(tokens); + } + + static escape(pointer: string) { + return JsonPointerLib.escape(pointer); } } - -JsonPointerLib._origParse = JsonPointerLib.parse; JsonPointerLib.parse = JsonPointer.parse; - - Object.assign(JsonPointer, JsonPointerLib); export default JsonPointer; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.ts similarity index 94% rename from lib/utils/SchemaManager.js rename to lib/utils/SchemaManager.ts index ecef93df..71ee9222 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.ts @@ -1,17 +1,20 @@ 'use strict'; -import JsonSchemaRefParser from 'json-schema-ref-parser'; + +import JsonSchemaRefParser from 'json-schema-ref-parser/dist/ref-parser'; import JsonPointer from './JsonPointer'; import {methods as swaggerMethods} from './swagger-defs'; -export default class SchemaManager { +export class SchemaManager { + private _schema:any = {}; + private _instance:any; + + apiUrl: string; constructor() { if (SchemaManager.prototype._instance) { return SchemaManager.prototype._instance; } SchemaManager.prototype._instance = this; - - this._schema = {}; } static instance() { @@ -117,7 +120,7 @@ export default class SchemaManager { } /* returns ES6 Map */ - buildMenuTree() { + buildMenuTree():Map { let tag2MethodMapping = new Map(); let definedTags = this._schema.tags || []; @@ -142,7 +145,7 @@ export default class SchemaManager { tags = ['[Other]']; } let methodPointer = JsonPointer.compile(['paths', path, method]); - let methodSummary = methodInfo.summary; + let methodSummary = methodInfo.summary || methodInfo.operationId; for (let tag of tags) { let tagDetails = tag2MethodMapping.get(tag); if (!tagDetails) { diff --git a/lib/utils/browser-update.js b/lib/utils/browser-update.ts similarity index 86% rename from lib/utils/browser-update.js rename to lib/utils/browser-update.ts index 7e08bc7c..bf54a275 100644 --- a/lib/utils/browser-update.js +++ b/lib/utils/browser-update.ts @@ -7,4 +7,4 @@ function $buo_f(){ document.body.appendChild(e); } try {document.addEventListener('DOMContentLoaded', $buo_f, false);} -catch(e){window.attachEvent('onload', $buo_f);} +catch(e){window['attachEvent']('onload', $buo_f);} diff --git a/lib/utils/helpers.js b/lib/utils/helpers.ts similarity index 100% rename from lib/utils/helpers.js rename to lib/utils/helpers.ts diff --git a/lib/utils/pipes.js b/lib/utils/pipes.ts similarity index 89% rename from lib/utils/pipes.js rename to lib/utils/pipes.ts index fb30e0a9..c5103c28 100644 --- a/lib/utils/pipes.js +++ b/lib/utils/pipes.ts @@ -3,19 +3,20 @@ import {Pipe} from '@angular/core'; import {isString, stringify, isBlank} from '@angular/core/src/facade/lang'; import {BaseException} from '@angular/core/src/facade/exceptions'; -import {JsonPointer} from './JsonPointer'; +import JsonPointer from './JsonPointer'; -import Prism from '../../prismjs-bundle'; +//import '../../prismjs-bundle'; +declare var Prism: any; -import 'prismjs/themes/prism-dark.css!css'; -import 'hint.css/hint.base.css!css'; +//import 'prismjs/themes/prism-dark.css!css'; +//import 'hint.css/hint.base.css!css'; import marked from 'marked'; // in gfm mode marked doesn't parse #Heading (without space after #) as heading // https://github.com/chjj/marked/issues/642 -marked.Lexer.rules.gfm.heading = marked.Lexer.rules.normal.heading; -marked.Lexer.rules.tables.heading = marked.Lexer.rules.normal.heading; +marked['Lexer'].rules.gfm.heading = marked['Lexer'].rules.normal.heading; +marked['Lexer'].rules.tables.heading = marked['Lexer'].rules.normal.heading; marked.setOptions({ renderer: new marked.Renderer(), diff --git a/lib/utils/prismjs-bundle.ts b/lib/utils/prismjs-bundle.ts new file mode 100644 index 00000000..e69de29b diff --git a/lib/utils/swagger-defs.js b/lib/utils/swagger-defs.ts similarity index 100% rename from lib/utils/swagger-defs.js rename to lib/utils/swagger-defs.ts diff --git a/package.json b/package.json index c40c1599..f37422b1 100644 --- a/package.json +++ b/package.json @@ -63,16 +63,39 @@ "overrides": { "github:Robdel12/DropKick@2.1.7": { "format": "global" + }, + "npm:@angular/core@2.0.0-rc.1": { + "main": "esm/index.js", + "format": "esm" + }, + "npm:@angular/common@2.0.0-rc.1": { + "main": "esm/index.js", + "format": "esm" + }, + "npm:@angular/compiler@2.0.0-rc.1": { + "main": "esm/index.js", + "format": "esm" + }, + "npm:@angular/platform-browser-dynamic@2.0.0-rc.1": { + "main": "esm/index.js", + "format": "esm" + }, + "npm:@angular/platform-browser@2.0.0-rc.1": { + "main": "esm/index.js", + "format": "esm" } } }, "devDependencies": { + "@angular/compiler-cli": "^0.2.0", + "@angular/platform-server": "^2.0.0-rc.1", "babel-eslint": "^4.1.6", "babel-polyfill": "^6.3.14", "branch-release": "^0.3.2", "browser-sync": "^2.10.1", "del": "^2.2.0", "deploy-to-gh-pages": "^1.0.0", + "dropkickjs": "github:robdel12/DropKick", "gulp": "^3.9.1", "gulp-concat": "^2.6.0", "gulp-eslint": "^1.1.1", @@ -87,6 +110,7 @@ "istanbul": "github:gotwarlost/istanbul#source-map", "jasmine-core": "^2.4.1", "jasmine-spec-reporter": "^2.4.0", + "json-schema-instantiator": "^0.3.0", "jspm": "^0.16.34", "karma": "^0.13.15", "karma-babel-preprocessor": "^5.2.2", @@ -101,17 +125,35 @@ "karma-regex-preprocessor": "github:makern/karma-regex-preprocessor", "karma-should": "^1.0.0", "karma-sinon": "^1.0.4", + "node-sass": "^3.7.0", "phantomjs-prebuilt": "^2.1.7", "protractor": "^3.0.0", "reflect-metadata": "^0.1.2", "require-dir": "^0.3.0", "run-sequence": "^1.1.5", + "rxjs-es": "^5.0.0-beta.7", "shelljs": "^0.7.0", "should": "^8.0.2", "sinon": "^1.17.2", "systemjs-builder": "^0.15.16", + "typescript": "^1.8.10", "vinyl-paths": "^2.0.0", "yargs": "^4.7.1", "zone.js": "^0.6.12" + }, + "dependencies": { + "@angular/common": "^2.0.0-rc.1", + "@angular/compiler": "^2.0.0-rc.1", + "@angular/core": "^2.0.0-rc.1", + "@angular/platform-browser": "^2.0.0-rc.1", + "@angular/platform-browser-dynamic": "^2.0.0-rc.1", + "gulp-inline-ng2-template": "^1.1.4", + "json-pointer": "^0.5.0", + "json-schema-ref-parser": "^3.1.2", + "marked": "^0.3.5", + "rollup-plugin-commonjs": "^2.2.1", + "rxjs": "^5.0.0-beta.6", + "scrollparent": "^1.0.0", + "zone.js": "^0.6.12" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..d2f27ae8 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,58 @@ +import nodeResolve from 'rollup-plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; + +class RollupNG2 { + constructor(options) { + this.options = options; + } + resolveId(id, from) { + if (id.startsWith('rxjs/')) { + return `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`; + } + + if(id.startsWith('@angular/core')){ + if(id === '@angular/core'){ + return `${__dirname}/node_modules/@angular/core/esm/index.js`; + } + return `${__dirname}/node_modules/@angular/core/esm/${id.split('@angular/core').pop()}.js`; + } + if(id.startsWith('@angular/common')){ + if(id === '@angular/common'){ + return `${__dirname}/node_modules/@angular/common/esm/index.js`; + } + return `${__dirname}/node_modules/@angular/common/esm/${id.split('@angular/common').pop()}.js`; + } + if(id.startsWith('@angular/platform-browser-dynamic')){ + if(id === '@angular/platform-browser-dynamic'){ + return `${__dirname}/node_modules/@angular/platform-browser-dynamic/esm/index.js`; + } + return `${__dirname}/node_modules/@angular/platform-browser-dynamic/esm/${id.split('@angular/platform-browser-dynamic').pop()}.js`; + } + if(id.startsWith('@angular/platform-browser')){ + if(id === '@angular/platform-browser'){ + return `${__dirname}/node_modules/@angular/platform-browser/esm/index.js`; + } + return `${__dirname}/node_modules/@angular/platform-browser/esm/${id.split('@angular/platform-browser').pop()}.js`; + } + } +} + +const rollupNG2 = (config) => new RollupNG2(config); +export default { + entry: './.tmp-es/index.js', + dest: 'dist/vendor.es2015.js', + format: 'iife', + moduleName: 'ReDoc', + plugins: [ + //typescript(), + rollupNG2(), + nodeResolve({ jsnext: true, main: true, browser: true }), + commonjs({ + // non-CommonJS modules will be ignored, but you can also + // specifically include/exclude files + include: 'node_modules/**', // Default: undefined + exclude: [ 'node_modules/@angular/**', 'node_modules/rxjs/**', 'node_modules/rxjs-es/**' ], // Default: undefined + namedExports: { 'marked': ['marked'] } // Default: undefined + }) + ] +} \ No newline at end of file diff --git a/system.config.js b/system.config.js index 2983ac4c..19d30682 100644 --- a/system.config.js +++ b/system.config.js @@ -138,15 +138,12 @@ System.config({ "browserify-zlib": "npm:browserify-zlib@0.1.4" }, "npm:@angular/common@2.0.0-rc.1": { - "@angular/core": "npm:@angular/core@2.0.0-rc.1", - "process": "github:jspm/nodelibs-process@0.1.2" + "@angular/core": "npm:@angular/core@2.0.0-rc.1" }, "npm:@angular/compiler@2.0.0-rc.1": { - "@angular/core": "npm:@angular/core@2.0.0-rc.1", - "process": "github:jspm/nodelibs-process@0.1.2" + "@angular/core": "npm:@angular/core@2.0.0-rc.1" }, "npm:@angular/core@2.0.0-rc.1": { - "process": "github:jspm/nodelibs-process@0.1.2", "rxjs": "npm:rxjs@5.0.0-beta.6", "zone.js": "npm:zone.js@0.6.12" }, @@ -154,14 +151,12 @@ System.config({ "@angular/common": "npm:@angular/common@2.0.0-rc.1", "@angular/compiler": "npm:@angular/compiler@2.0.0-rc.1", "@angular/core": "npm:@angular/core@2.0.0-rc.1", - "@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.1", - "process": "github:jspm/nodelibs-process@0.1.2" + "@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.1" }, "npm:@angular/platform-browser@2.0.0-rc.1": { "@angular/common": "npm:@angular/common@2.0.0-rc.1", "@angular/compiler": "npm:@angular/compiler@2.0.0-rc.1", - "@angular/core": "npm:@angular/core@2.0.0-rc.1", - "process": "github:jspm/nodelibs-process@0.1.2" + "@angular/core": "npm:@angular/core@2.0.0-rc.1" }, "npm:amdefine@1.0.0": { "fs": "github:jspm/nodelibs-fs@0.1.2", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..5cd5269e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "module": "es6", + "target": "es6", + "noImplicitAny": false, + "sourceMap": false, + "outDir": ".tmp-es/", + "moduleResolution": "node" + }, + "exclude": [ + "node_modules", + "lib", + "jspm_packages", + "build", + "docs", + "*.spec.js" + ] +} diff --git a/typings.json b/typings.json new file mode 100644 index 00000000..457bd417 --- /dev/null +++ b/typings.json @@ -0,0 +1,11 @@ +{ + "globalDevDependencies": { + "jasmine": "registry:dt/jasmine#2.2.0+20160505161446" + }, + "globalDependencies": { + "marked": "registry:dt/marked#0.0.0+20160325085301" + }, + "ambientDevDependencies": { + "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2" + } +} \ No newline at end of file diff --git a/typings/dropkick.d.ts b/typings/dropkick.d.ts new file mode 100644 index 00000000..4b3ee972 --- /dev/null +++ b/typings/dropkick.d.ts @@ -0,0 +1,7 @@ + +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts +declare module "dropkickjs" { + var x: any; + export default x; +} \ No newline at end of file diff --git a/typings/globals/jasmine/index.d.ts b/typings/globals/jasmine/index.d.ts new file mode 100644 index 00000000..d1a7c8ae --- /dev/null +++ b/typings/globals/jasmine/index.d.ts @@ -0,0 +1,501 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/36a1be34dbe202c665b3ddafd50824f78c09eea3/jasmine/jasmine.d.ts +declare function describe(description: string, specDefinitions: () => void): void; +declare function fdescribe(description: string, specDefinitions: () => void): void; +declare function xdescribe(description: string, specDefinitions: () => void): void; + +declare function it(expectation: string, assertion?: () => void, timeout?: number): void; +declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void; +declare function fit(expectation: string, assertion?: () => void, timeout?: number): void; +declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void; +declare function xit(expectation: string, assertion?: () => void, timeout?: number): void; +declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void; + +/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */ +declare function pending(reason?: string): void; + +declare function beforeEach(action: () => void, timeout?: number): void; +declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void; +declare function afterEach(action: () => void, timeout?: number): void; +declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void; + +declare function beforeAll(action: () => void, timeout?: number): void; +declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void; +declare function afterAll(action: () => void, timeout?: number): void; +declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; + +declare function expect(spy: Function): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; + +declare function fail(e?: any): void; +/** Action method that should be called when the async work is complete */ +interface DoneFn extends Function { + (): void; + + /** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */ + fail: (message?: Error|string) => void; +} + +declare function spyOn(object: any, method: string): jasmine.Spy; + +declare function runs(asyncMethod: Function): void; +declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; +declare function waits(timeout?: number): void; + +declare namespace jasmine { + + var clock: () => Clock; + + function any(aclass: any): Any; + function anything(): Any; + function arrayContaining(sample: any[]): ArrayContaining; + function objectContaining(sample: any): ObjectContaining; + function createSpy(name: string, originalFn?: Function): Spy; + function createSpyObj(baseName: string, methodNames: any[]): any; + function createSpyObj(baseName: string, methodNames: any[]): T; + function pp(value: any): string; + function getEnv(): Env; + function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + function addMatchers(matchers: CustomMatcherFactories): void; + function stringMatching(str: string): Any; + function stringMatching(str: RegExp): Any; + + interface Any { + + new (expectedClass: any): any; + + jasmineMatches(other: any): boolean; + jasmineToString(): string; + } + + // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains() + interface ArrayLike { + length: number; + [n: number]: T; + } + + interface ArrayContaining { + new (sample: any[]): any; + + asymmetricMatch(other: any): boolean; + jasmineToString(): string; + } + + interface ObjectContaining { + new (sample: any): any; + + jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; + jasmineToString(): string; + } + + interface Block { + + new (env: Env, func: SpecFunction, spec: Spec): any; + + execute(onComplete: () => void): void; + } + + interface WaitsBlock extends Block { + new (env: Env, timeout: number, spec: Spec): any; + } + + interface WaitsForBlock extends Block { + new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; + } + + interface Clock { + install(): void; + uninstall(): void; + /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */ + tick(ms: number): void; + mockDate(date?: Date): void; + } + + interface CustomEqualityTester { + (first: any, second: any): boolean; + } + + interface CustomMatcher { + compare(actual: T, expected: T): CustomMatcherResult; + compare(actual: any, expected: any): CustomMatcherResult; + } + + interface CustomMatcherFactory { + (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; + } + + interface CustomMatcherFactories { + [index: string]: CustomMatcherFactory; + } + + interface CustomMatcherResult { + pass: boolean; + message?: string; + } + + interface MatchersUtil { + equals(a: any, b: any, customTesters?: Array): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; + buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; + } + + interface Env { + setTimeout: any; + clearTimeout: void; + setInterval: any; + clearInterval: void; + updateInterval: number; + + currentSpec: Spec; + + matchersClass: Matchers; + + version(): any; + versionString(): string; + nextSpecId(): number; + addReporter(reporter: Reporter): void; + execute(): void; + describe(description: string, specDefinitions: () => void): Suite; + // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these + beforeEach(beforeEachFunction: () => void): void; + beforeAll(beforeAllFunction: () => void): void; + currentRunner(): Runner; + afterEach(afterEachFunction: () => void): void; + afterAll(afterAllFunction: () => void): void; + xdescribe(desc: string, specDefinitions: () => void): XSuite; + it(description: string, func: () => void): Spec; + // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these + xit(desc: string, func: () => void): XSpec; + compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; + compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; + contains_(haystack: any, needle: any): boolean; + addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + addMatchers(matchers: CustomMatcherFactories): void; + specFilter(spec: Spec): boolean; + } + + interface FakeTimer { + + new (): any; + + reset(): void; + tick(millis: number): void; + runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; + scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; + } + + interface HtmlReporter { + new (): any; + } + + interface HtmlSpecFilter { + new (): any; + } + + interface Result { + type: string; + } + + interface NestedResults extends Result { + description: string; + + totalCount: number; + passedCount: number; + failedCount: number; + + skipped: boolean; + + rollupCounts(result: NestedResults): void; + log(values: any): void; + getItems(): Result[]; + addResult(result: Result): void; + passed(): boolean; + } + + interface MessageResult extends Result { + values: any; + trace: Trace; + } + + interface ExpectationResult extends Result { + matcherName: string; + passed(): boolean; + expected: any; + actual: any; + message: string; + trace: Trace; + } + + interface Trace { + name: string; + message: string; + stack: any; + } + + interface PrettyPrinter { + + new (): any; + + format(value: any): void; + iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; + emitScalar(value: any): void; + emitString(value: string): void; + emitArray(array: any[]): void; + emitObject(obj: any): void; + append(value: any): void; + } + + interface StringPrettyPrinter extends PrettyPrinter { + } + + interface Queue { + + new (env: any): any; + + env: Env; + ensured: boolean[]; + blocks: Block[]; + running: boolean; + index: number; + offset: number; + abort: boolean; + + addBefore(block: Block, ensure?: boolean): void; + add(block: any, ensure?: boolean): void; + insertNext(block: any, ensure?: boolean): void; + start(onComplete?: () => void): void; + isRunning(): boolean; + next_(): void; + results(): NestedResults; + } + + interface Matchers { + + new (env: Env, actual: any, spec: Env, isNot?: boolean): any; + + env: Env; + actual: any; + spec: Env; + isNot?: boolean; + message(): any; + + toBe(expected: any, expectationFailOutput?: any): boolean; + toEqual(expected: any, expectationFailOutput?: any): boolean; + toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; + toBeDefined(expectationFailOutput?: any): boolean; + toBeUndefined(expectationFailOutput?: any): boolean; + toBeNull(expectationFailOutput?: any): boolean; + toBeNaN(): boolean; + toBeTruthy(expectationFailOutput?: any): boolean; + toBeFalsy(expectationFailOutput?: any): boolean; + toHaveBeenCalled(): boolean; + toHaveBeenCalledWith(...params: any[]): boolean; + toHaveBeenCalledTimes(expected: number): boolean; + toContain(expected: any, expectationFailOutput?: any): boolean; + toBeLessThan(expected: number, expectationFailOutput?: any): boolean; + toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; + toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; + toThrow(expected?: any): boolean; + toThrowError(message?: string | RegExp): boolean; + toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean; + not: Matchers; + + Any: Any; + } + + interface Reporter { + reportRunnerStarting(runner: Runner): void; + reportRunnerResults(runner: Runner): void; + reportSuiteResults(suite: Suite): void; + reportSpecStarting(spec: Spec): void; + reportSpecResults(spec: Spec): void; + log(str: string): void; + } + + interface MultiReporter extends Reporter { + addReporter(reporter: Reporter): void; + } + + interface Runner { + + new (env: Env): any; + + execute(): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + beforeAll(beforeAllFunction: SpecFunction): void; + afterAll(afterAllFunction: SpecFunction): void; + finishCallback(): void; + addSuite(suite: Suite): void; + add(block: Block): void; + specs(): Spec[]; + suites(): Suite[]; + topLevelSuites(): Suite[]; + results(): NestedResults; + } + + interface SpecFunction { + (spec?: Spec): void; + } + + interface SuiteOrSpec { + id: number; + env: Env; + description: string; + queue: Queue; + } + + interface Spec extends SuiteOrSpec { + + new (env: Env, suite: Suite, description: string): any; + + suite: Suite; + + afterCallbacks: SpecFunction[]; + spies_: Spy[]; + + results_: NestedResults; + matchersClass: Matchers; + + getFullName(): string; + results(): NestedResults; + log(arguments: any): any; + runs(func: SpecFunction): Spec; + addToQueue(block: Block): void; + addMatcherResult(result: Result): void; + expect(actual: any): any; + waits(timeout: number): Spec; + waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; + fail(e?: any): void; + getMatchersClass_(): Matchers; + addMatchers(matchersPrototype: CustomMatcherFactories): void; + finishCallback(): void; + finish(onComplete?: () => void): void; + after(doAfter: SpecFunction): void; + execute(onComplete?: () => void): any; + addBeforesAndAftersToQueue(): void; + explodes(): void; + spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; + removeAllSpies(): void; + } + + interface XSpec { + id: number; + runs(): void; + } + + interface Suite extends SuiteOrSpec { + + new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; + + parentSuite: Suite; + + getFullName(): string; + finish(onComplete?: () => void): void; + beforeEach(beforeEachFunction: SpecFunction): void; + afterEach(afterEachFunction: SpecFunction): void; + beforeAll(beforeAllFunction: SpecFunction): void; + afterAll(afterAllFunction: SpecFunction): void; + results(): NestedResults; + add(suiteOrSpec: SuiteOrSpec): void; + specs(): Spec[]; + suites(): Suite[]; + children(): any[]; + execute(onComplete?: () => void): void; + } + + interface XSuite { + execute(): void; + } + + interface Spy { + (...params: any[]): any; + + identity: string; + and: SpyAnd; + calls: Calls; + mostRecentCall: { args: any[]; }; + argsForCall: any[]; + wasCalled: boolean; + } + + interface SpyAnd { + /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ + callThrough(): Spy; + /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ + returnValue(val: any): Spy; + /** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */ + returnValues(...values: any[]): Spy; + /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ + callFake(fn: Function): Spy; + /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ + throwError(msg: string): Spy; + /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ + stub(): Spy; + } + + interface Calls { + /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ + any(): boolean; + /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ + count(): number; + /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ + argsFor(index: number): any[]; + /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ + allArgs(): any[]; + /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ + all(): CallInfo[]; + /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ + mostRecent(): CallInfo; + /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ + first(): CallInfo; + /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ + reset(): void; + } + + interface CallInfo { + /** The context (the this) for the call */ + object: any; + /** All arguments passed to the call */ + args: any[]; + /** The return value of the call */ + returnValue: any; + } + + interface Util { + inherit(childClass: Function, parentClass: Function): any; + formatException(e: any): any; + htmlEscape(str: string): string; + argsToArray(args: any): any; + extend(destination: any, source: any): any; + } + + interface JsApiReporter extends Reporter { + + started: boolean; + finished: boolean; + result: any; + messages: any; + + new (): any; + + suites(): Suite[]; + summarize_(suiteOrSpec: SuiteOrSpec): any; + results(): any; + resultsForSpec(specId: any): any; + log(str: any): any; + resultsForSpecs(specIds: any): any; + summarizeResult_(result: any): any; + } + + interface Jasmine { + Spec: Spec; + clock: Clock; + util: Util; + } + + export var HtmlReporter: HtmlReporter; + export var HtmlSpecFilter: HtmlSpecFilter; + export var DEFAULT_TIMEOUT_INTERVAL: number; +} \ No newline at end of file diff --git a/typings/globals/jasmine/typings.json b/typings/globals/jasmine/typings.json new file mode 100644 index 00000000..4570b84e --- /dev/null +++ b/typings/globals/jasmine/typings.json @@ -0,0 +1,8 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/36a1be34dbe202c665b3ddafd50824f78c09eea3/jasmine/jasmine.d.ts", + "raw": "registry:dt/jasmine#2.2.0+20160505161446", + "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/36a1be34dbe202c665b3ddafd50824f78c09eea3/jasmine/jasmine.d.ts" + } +} diff --git a/typings/globals/json-pointer/index.d.ts b/typings/globals/json-pointer/index.d.ts new file mode 100644 index 00000000..8b93d3eb --- /dev/null +++ b/typings/globals/json-pointer/index.d.ts @@ -0,0 +1,80 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts +declare module "json-pointer" { + function JSON_Pointer(object: Object): JSON_Pointer.JSON_PointerWrap; + + namespace JSON_Pointer { + /** + * Wrap an object with accessors + */ + /** + * Looks up a JSON pointer in an object. + */ + function get(object: Object, pointer: string): any; + /** + * Set a value for a JSON pointer on object. + */ + function set(object: Object, pointer: string, value: any): void; + /** + * Removes an attribute of object referenced by pointer + */ + function remove(object: Object, pointer: string): void; + /** + * Creates a dictionary object (pointer -> value). + */ + function dict(object: Object): Object; + /** + * Just like: each(pointer.dict(obj), iterator); + */ + function walk(object: Object, iterator: (value: any, key: string) => void): void; + /** + * Tests if an object has a value for a JSON pointer. + */ + function has(object: Object, pointer: string): boolean; + /** + * Escapes a reference token. + */ + function escape(str: string): string; + /** + * Unescape a reference token. + */ + function unescape(str: string): string; + /** + * Converts a JSON pointer into an array of reference tokens. + */ + function parse(str: string): string[]; + /** + * Builds a json pointer from an array of reference tokens. + */ + function compile(str: string[]): string; + + interface JSON_PointerWrap { + /** + * Looks up a JSON pointer in an object. + */ + get(pointer: string): any; + /** + * Set a value for a JSON pointer on object. + */ + set(pointer: string, value: any): void; + /** + * Removes an attribute of object referenced by pointer + */ + remove(pointer: string): void; + /** + * Creates a dictionary object (pointer -> value). + */ + dict(): Object; + /** + * Just like: each(pointer.dict(obj), iterator); + */ + walk(iterator: (value: any, key: string) => void): void; + /** + * Tests if an object has a value for a JSON pointer. + */ + has(pointer: string): boolean; + } + } + + export default JSON_Pointer; +} \ No newline at end of file diff --git a/typings/globals/json-pointer/typings.json b/typings/globals/json-pointer/typings.json new file mode 100644 index 00000000..3f323b65 --- /dev/null +++ b/typings/globals/json-pointer/typings.json @@ -0,0 +1,8 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts", + "raw": "registry:dt/json-pointer#1.0.0+20160317120654", + "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts" + } +} diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 00000000..ac6df80a --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1,4 @@ +/// +/// +/// + diff --git a/typings/json-schema-instantiator.d.ts b/typings/json-schema-instantiator.d.ts new file mode 100644 index 00000000..8a06186f --- /dev/null +++ b/typings/json-schema-instantiator.d.ts @@ -0,0 +1,6 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts +declare module "json-schema-instantiator" { + var x: any; + export default x; +} \ No newline at end of file diff --git a/typings/json-schema-ref-parser.d.ts b/typings/json-schema-ref-parser.d.ts new file mode 100644 index 00000000..be852cc7 --- /dev/null +++ b/typings/json-schema-ref-parser.d.ts @@ -0,0 +1,6 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts +declare module "json-schema-ref-parser/dist/ref-parser" { + var x: any; + export default x; +} \ No newline at end of file diff --git a/typings/marked.d.ts b/typings/marked.d.ts new file mode 100644 index 00000000..be77f66a --- /dev/null +++ b/typings/marked.d.ts @@ -0,0 +1,7 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts + +declare module "marked" { + var x: any; + export default x; +} \ No newline at end of file diff --git a/typings/modules/chai/index.d.ts b/typings/modules/chai/index.d.ts new file mode 100644 index 00000000..0d262aee --- /dev/null +++ b/typings/modules/chai/index.d.ts @@ -0,0 +1,547 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/main.d.ts +declare module '~chai~assertion-error/main' { +// Type definitions for assertion-error 1.0.0 +// Project: https://github.com/chaijs/assertion-error +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +export class AssertionError implements Error { + constructor(message: string, props?: any, ssf?: Function); + public name: string; + public message: string; + public showDiff: boolean; + public stack: string; + + /** + * Allow errors to be converted to JSON for static transfer. + * + * @param {Boolean} include stack (default: `true`) + * @return {Object} object that can be `JSON.stringify` + */ + public toJSON(stack: boolean): Object; +} +} +declare module '~chai~assertion-error' { +import alias = require('~chai~assertion-error/main'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Assert.d.ts +declare module '~chai/lib/Assert' { +export interface AssertStatic extends Assert { +} + +export interface Assert { + /** + * @param expression Expression to test for truthiness. + * @param message Message to display on error. + */ + (expression: any, message?: string): void; + (expression: any, messageCallback: () => string): void; + + fail(actual?: any, expected?: any, msg?: string, operator?: string): void; + + ok(val: any, msg?: string): void; + isOk(val: any, msg?: string): void; + notOk(val: any, msg?: string): void; + isNotOk(val: any, msg?: string): void; + + equal(act: any, exp: any, msg?: string): void; + notEqual(act: any, exp: any, msg?: string): void; + + strictEqual(act: any, exp: any, msg?: string): void; + notStrictEqual(act: any, exp: any, msg?: string): void; + + deepEqual(act: any, exp: any, msg?: string): void; + notDeepEqual(act: any, exp: any, msg?: string): void; + + isTrue(val: any, msg?: string): void; + isFalse(val: any, msg?: string): void; + + isNotTrue(val: any, msg?: string): void; + isNotFalse(val: any, msg?: string): void; + + isNull(val: any, msg?: string): void; + isNotNull(val: any, msg?: string): void; + + isUndefined(val: any, msg?: string): void; + isDefined(val: any, msg?: string): void; + + isNaN(val: any, msg?: string): void; + isNotNaN(val: any, msg?: string): void; + + isAbove(val: number, abv: number, msg?: string): void; + isBelow(val: number, blw: number, msg?: string): void; + + isAtLeast(val: number, atlst: number, msg?: string): void; + isAtMost(val: number, atmst: number, msg?: string): void; + + isFunction(val: any, msg?: string): void; + isNotFunction(val: any, msg?: string): void; + + isObject(val: any, msg?: string): void; + isNotObject(val: any, msg?: string): void; + + isArray(val: any, msg?: string): void; + isNotArray(val: any, msg?: string): void; + + isString(val: any, msg?: string): void; + isNotString(val: any, msg?: string): void; + + isNumber(val: any, msg?: string): void; + isNotNumber(val: any, msg?: string): void; + + isBoolean(val: any, msg?: string): void; + isNotBoolean(val: any, msg?: string): void; + + typeOf(val: any, type: string, msg?: string): void; + notTypeOf(val: any, type: string, msg?: string): void; + + instanceOf(val: any, type: Function, msg?: string): void; + notInstanceOf(val: any, type: Function, msg?: string): void; + + include(exp: string, inc: any, msg?: string): void; + include(exp: any[], inc: any, msg?: string): void; + include(exp: Object, inc: Object, msg?: string): void; + + notInclude(exp: string, inc: any, msg?: string): void; + notInclude(exp: any[], inc: any, msg?: string): void; + + match(exp: any, re: RegExp, msg?: string): void; + notMatch(exp: any, re: RegExp, msg?: string): void; + + property(obj: Object, prop: string, msg?: string): void; + notProperty(obj: Object, prop: string, msg?: string): void; + deepProperty(obj: Object, prop: string, msg?: string): void; + notDeepProperty(obj: Object, prop: string, msg?: string): void; + + propertyVal(obj: Object, prop: string, val: any, msg?: string): void; + propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; + + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; + + lengthOf(exp: any, len: number, msg?: string): void; + + throw(fn: Function, msg?: string): void; + throw(fn: Function, regExp: RegExp): void; + throw(fn: Function, errType: Function, msg?: string): void; + throw(fn: Function, errType: Function, regExp: RegExp): void; + + throws(fn: Function, msg?: string): void; + throws(fn: Function, regExp: RegExp): void; + throws(fn: Function, errType: Function, msg?: string): void; + throws(fn: Function, errType: Function, regExp: RegExp): void; + + Throw(fn: Function, msg?: string): void; + Throw(fn: Function, regExp: RegExp): void; + Throw(fn: Function, errType: Function, msg?: string): void; + Throw(fn: Function, errType: Function, regExp: RegExp): void; + + doesNotThrow(fn: Function, msg?: string): void; + doesNotThrow(fn: Function, regExp: RegExp): void; + doesNotThrow(fn: Function, errType: Function, msg?: string): void; + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; + + operator(val: any, operator: string, val2: any, msg?: string): void; + closeTo(act: number, exp: number, delta: number, msg?: string): void; + approximately(act: number, exp: number, delta: number, msg?: string): void; + + sameMembers(set1: any[], set2: any[], msg?: string): void; + sameDeepMembers(set1: any[], set2: any[], msg?: string): void; + includeMembers(superset: any[], subset: any[], msg?: string): void; + includeDeepMembers(superset: any[], subset: any[], msg?: string): void; + + ifError(val: any, msg?: string): void; + + isExtensible(obj: {}, msg?: string): void; + extensible(obj: {}, msg?: string): void; + isNotExtensible(obj: {}, msg?: string): void; + notExtensible(obj: {}, msg?: string): void; + + isSealed(obj: {}, msg?: string): void; + sealed(obj: {}, msg?: string): void; + isNotSealed(obj: {}, msg?: string): void; + notSealed(obj: {}, msg?: string): void; + + isFrozen(obj: Object, msg?: string): void; + frozen(obj: Object, msg?: string): void; + isNotFrozen(obj: Object, msg?: string): void; + notFrozen(obj: Object, msg?: string): void; + + oneOf(inList: any, list: any[], msg?: string): void; + + changes(fn: Function, obj: {}, property: string): void; + doesNotChange(fn: Function, obj: {}, property: string): void; + increases(fn: Function, obj: {}, property: string): void; + doesNotIncrease(fn: Function, obj: {}, property: string): void; + + decreases(fn: Function, obj: {}, property: string): void; + doesNotDecrease(fn: Function, obj: {}, property: string): void; + } +} +declare module 'chai/lib/Assert' { +import alias = require('~chai/lib/Assert'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Assertion.d.ts +declare module '~chai/lib/Assertion' { +export interface AssertionStatic { + (target?: any, message?: string, stack?: Function): Assertion; + new (target?: any, message?: string, stack?: Function): Assertion; +} + +export interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + not: Assertion; + deep: Deep; + any: KeyFilter; + all: KeyFilter; + a: TypeComparison; + an: TypeComparison; + include: Include; + includes: Include; + contain: Include; + contains: Include; + ok: Assertion; + true: Assertion; + false: Assertion; + null: Assertion; + undefined: Assertion; + NaN: Assertion; + exist: Assertion; + empty: Assertion; + arguments: Assertion; + Arguments: Assertion; + equal: Equal; + equals: Equal; + eq: Equal; + eql: Equal; + eqls: Equal; + property: Property; + ownProperty: OwnProperty; + haveOwnProperty: OwnProperty; + ownPropertyDescriptor: OwnPropertyDescriptor; + haveOwnPropertyDescriptor: OwnPropertyDescriptor; + length: Length; + lengthOf: Length; + match: Match; + matches: Match; + string(str: string, message?: string): Assertion; + keys: Keys; + key(str: string): Assertion; + throw: Throw; + throws: Throw; + Throw: Throw; + respondTo: RespondTo; + respondsTo: RespondTo; + itself: Assertion; + satisfy: Satisfy; + satisfies: Satisfy; + closeTo: CloseTo; + approximately: CloseTo; + members: Members; + increase: PropertyChange; + increases: PropertyChange; + decrease: PropertyChange; + decreases: PropertyChange; + change: PropertyChange; + changes: PropertyChange; + extensible: Assertion; + sealed: Assertion; + frozen: Assertion; + oneOf(list: any[], message?: string): Assertion; +} + +export interface LanguageChains { + to: Assertion; + be: Assertion; + been: Assertion; + is: Assertion; + that: Assertion; + which: Assertion; + and: Assertion; + has: Assertion; + have: Assertion; + with: Assertion; + at: Assertion; + of: Assertion; + same: Assertion; +} + +export interface NumericComparison { + above: NumberComparer; + gt: NumberComparer; + greaterThan: NumberComparer; + least: NumberComparer; + gte: NumberComparer; + below: NumberComparer; + lt: NumberComparer; + lessThan: NumberComparer; + most: NumberComparer; + lte: NumberComparer; + within(start: number, finish: number, message?: string): Assertion; +} + +export interface NumberComparer { + (value: number, message?: string): Assertion; +} + +export interface TypeComparison { + (type: string, message?: string): Assertion; + instanceof: InstanceOf; + instanceOf: InstanceOf; +} + +export interface InstanceOf { + (constructor: Object, message?: string): Assertion; +} + +export interface CloseTo { + (expected: number, delta: number, message?: string): Assertion; +} + +export interface Deep { + equal: Equal; + equals: Equal; + eq: Equal; + include: Include; + property: Property; + members: Members; +} + +export interface KeyFilter { + keys: Keys; +} + +export interface Equal { + (value: any, message?: string): Assertion; +} + +export interface Property { + (name: string, value?: any, message?: string): Assertion; +} + +export interface OwnProperty { + (name: string, message?: string): Assertion; +} + +export interface OwnPropertyDescriptor { + (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; + (name: string, message?: string): Assertion; +} + +export interface Length extends LanguageChains, NumericComparison { + (length: number, message?: string): Assertion; +} + +export interface Include { + (value: Object, message?: string): Assertion; + (value: string, message?: string): Assertion; + (value: number, message?: string): Assertion; + string(value: string, message?: string): Assertion; + keys: Keys; + members: Members; + any: KeyFilter; + all: KeyFilter; +} + +export interface Match { + (regexp: RegExp | string, message?: string): Assertion; +} + +export interface Keys { + (...keys: any[]): Assertion; + (keys: any[]): Assertion; + (keys: Object): Assertion; +} + +export interface Throw { + (): Assertion; + (expected: string, message?: string): Assertion; + (expected: RegExp, message?: string): Assertion; + (constructor: Error, expected?: string, message?: string): Assertion; + (constructor: Error, expected?: RegExp, message?: string): Assertion; + (constructor: Function, expected?: string, message?: string): Assertion; + (constructor: Function, expected?: RegExp, message?: string): Assertion; +} + +export interface RespondTo { + (method: string, message?: string): Assertion; +} + +export interface Satisfy { + (matcher: Function, message?: string): Assertion; +} + +export interface Members { + (set: any[], message?: string): Assertion; +} + +export interface PropertyChange { + (object: Object, prop: string, msg?: string): Assertion; +} +} +declare module 'chai/lib/Assertion' { +import alias = require('~chai/lib/Assertion'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Expect.d.ts +declare module '~chai/lib/Expect' { +import {AssertionStatic} from '~chai/lib/Assertion'; + +export interface ExpectStatic extends AssertionStatic { + fail(actual?: any, expected?: any, message?: string, operator?: string): void; +} +} +declare module 'chai/lib/Expect' { +import alias = require('~chai/lib/Expect'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Should.d.ts +declare module '~chai/lib/Should' { +export interface Should extends ShouldAssertion { + not: ShouldAssertion; + fail(actual: any, expected: any, message?: string, operator?: string): void; +} + +export interface ShouldAssertion { + Throw: ShouldThrow; + throw: ShouldThrow; + equal(value1: any, value2: any, message?: string): void; + exist(value: any, message?: string): void; +} + +export interface ShouldThrow { + (actual: Function): void; + (actual: Function, expected: string | RegExp, message?: string): void; + (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void; +} +} +declare module 'chai/lib/Should' { +import alias = require('~chai/lib/Should'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Config.d.ts +declare module '~chai/lib/Config' { +export interface Config { + includeStack: boolean; + showDiff: boolean; + truncateThreshold: number; +} +} +declare module 'chai/lib/Config' { +import alias = require('~chai/lib/Config'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Utils.d.ts +declare module '~chai/lib/Utils' { +import {Assertion} from '~chai/lib/Assertion'; + +export interface PathInfo { + parent: any; + name: number|string; + value: any; + exists: boolean; +} + +export interface Utils { + addChainableMethod(ctx: any, name: string, chainingBehavior: (value: any) => void): void; + addMethod(ctx: any, name: string, method: (value: any) => void): void; + addProperty(ctx: any, name: string, getter: () => void): void; + expectTypes(obj: Object, types: string[]): void; + flag(obj: Object, key: string, value?: any): any; + getActual(obj: Object, actual?: any): any; + getEnumerableProperties(obj: Object): string[]; + getMessage(obj: Object, params: any[]): string; + getMessage(obj: Object, message: string, negateMessage: string): string; + getName(func: Function): string; + getPathInfo(path: string, obj: Object): PathInfo; + getPathValue(path: string, obj: Object): any; + getProperties(obj: Object): string[]; + hasProperty(obj: Object, name: string): boolean; + transferFlags(assertion: Assertion | any, obj: Object, includeAll?: boolean): void; + inspect(obj: any): any; +} +} +declare module 'chai/lib/Utils' { +import alias = require('~chai/lib/Utils'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Chai.d.ts +declare module '~chai/lib/Chai' { +import * as AE from '~chai~assertion-error'; + +import * as Assert from '~chai/lib/Assert'; +import * as A from '~chai/lib/Assertion'; +import * as Expect from '~chai/lib/Expect'; +import * as Should from '~chai/lib/Should'; +import * as Config from '~chai/lib/Config'; +import * as Utils from '~chai/lib/Utils'; + +namespace chai { + export interface AssertionStatic extends A.AssertionStatic {} + export class AssertionError extends AE.AssertionError {} + export var Assertion: A.AssertionStatic; + export var expect: Expect.ExpectStatic; + export var assert: Assert.AssertStatic; + export var config: Config.Config; + export var util: Utils.Utils; + export function should(): Should.Should; + export function Should(): Should.Should; + /** + * Provides a way to extend the internals of Chai + */ + export function use(fn: (chai: any, utils: Utils.Utils) => void): typeof chai; +} + +export = chai; + +/* tslint:disable:no-internal-module */ +global { + interface Object { + should: A.Assertion; + } +} +} +declare module 'chai/lib/Chai' { +import alias = require('~chai/lib/Chai'); +export = alias; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/index.d.ts +declare module '~chai/index' { +// Type definitions for chai 3.4.0 +// Project: http://chaijs.com/ +// Original Definitions by: Jed Mao , +// Bart van der Schoor , +// Andrew Brown , +// Olivier Chevet , +// Matt Wistrand + +import chai = require('~chai/lib/Chai'); + +export = chai; +} +declare module 'chai/index' { +import alias = require('~chai/index'); +export = alias; +} +declare module 'chai' { +import alias = require('~chai/index'); +export = alias; +} diff --git a/typings/modules/chai/typings.json b/typings/modules/chai/typings.json new file mode 100644 index 00000000..f81ca6bf --- /dev/null +++ b/typings/modules/chai/typings.json @@ -0,0 +1,21 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/typings.json", + "raw": "registry:npm/chai#3.5.0+20160415060238", + "main": "index.d.ts", + "global": false, + "dependencies": { + "assertion-error": { + "src": "https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/typings.json", + "raw": "github:typed-typings/npm-assertion-error#105841317bd2bdd5d110bfb763e49e482a77230d", + "main": "main.d.ts", + "global": false, + "name": "assertion-error", + "type": "typings" + } + }, + "name": "chai", + "type": "typings" + } +} diff --git a/typings/scrollparent.d.ts b/typings/scrollparent.d.ts new file mode 100644 index 00000000..05b8f986 --- /dev/null +++ b/typings/scrollparent.d.ts @@ -0,0 +1,6 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts +declare module "scrollparent" { + var x: any; + export default x; +} \ No newline at end of file From 3629e34a5ab3f75a0499446c5f492d11535643c5 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 6 Jun 2016 19:32:20 +0300 Subject: [PATCH 02/20] Continue migrating to TS --- build/tasks/build.js | 33 ++++++--- karma.conf.js | 6 +- lib/components/Redoc/redoc.ts | 7 +- .../RequestSamples/request-samples.ts | 4 +- lib/components/SchemaSample/schema-sample.js | 70 +++++++++++++++++++ lib/components/SchemaSample/schema-sample.ts | 8 ++- lib/index.js | 12 ++++ lib/index.ts | 7 -- lib/shared/components/DropDown/drop-down.ts | 3 +- lib/utils/pipes.ts | 4 -- package.json | 20 ++++-- system.config.js | 22 +++--- tsconfig.json | 7 +- typings/dropkick.d.ts | 7 -- typings/dropkickjs.d.ts | 4 ++ typings/index.d.ts | 1 - typings/json-schema-instantiator.d.ts | 6 -- typings/json-schema-ref-parser.d.ts | 4 +- typings/openapi-sampler.d.ts | 3 + 19 files changed, 156 insertions(+), 72 deletions(-) create mode 100644 lib/components/SchemaSample/schema-sample.js create mode 100644 lib/index.js delete mode 100644 lib/index.ts delete mode 100644 typings/dropkick.d.ts create mode 100644 typings/dropkickjs.d.ts delete mode 100644 typings/json-schema-instantiator.d.ts create mode 100644 typings/openapi-sampler.d.ts diff --git a/build/tasks/build.js b/build/tasks/build.js index 692041d9..4183af1d 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -21,8 +21,9 @@ gulp.task('build', function (callback) { return callback(); } return runSequence( - //'clean', - 'concatPrism', + 'clean', + 'tsc', + 'inlineTemplates', 'bundle', 'concatDeps', 'copyDebug', @@ -39,19 +40,32 @@ gulp.task('copyDebug', () => { gulp.task('rebuild', function(done) { return runSequence( + 'tsc', + 'inlineTemplates', 'bundle', 'concatDeps', + 'copyDebug', done ); }); +gulp.task('tsc', function() { + exec('tsc -p ./tsconfig.json'); +}); + gulp.task('inlineTemplates', ['sass'], function() { - return gulp.src(paths.source, { base: './' }) + return gulp.src('.tmp/lib/**/*.js', { base: './tmp' }) .pipe(replace(/'(.*?)\.css'/g, '\'$1.scss\'')) - .pipe(inlineNg2Template({ - base: '/', + .pipe(inlineNg2Template({ + base: './', useRelativePaths: true, - styleProcessor: compileSass + styleProcessor: compileSass, + customFilePath: function(ext, file) { + var cwd = process.cwd(); + var relative = path.relative(cwd, file); + relative = relative.substring('5'); + return path.join(cwd, relative); + } })) .pipe(gulp.dest(paths.tmp)); }); @@ -62,7 +76,7 @@ function compileSass(ext, file) { file = file.replace('../../shared/styles/share-link', 'lib/shared/styles/share-link'); file = file.replace('../JsonSchema/lib/components/JsonSchema/json-schema-common', 'lib/components/JsonSchema/json-schema-common'); file = file.replace('../../styles/variables', 'lib/shared/styles/variables'); - + return sassCopm.renderSync({data: file}).css; } @@ -97,7 +111,8 @@ gulp.task('concatDeps', ['concatPrism'], function() { }); gulp.task('bundle', function bundle(done) { - fs.existsSync('dist') || fs.mkdirSync('dist'); + mkdir('-p', 'dist'); + cp('lib/index.js', path.join(paths.tmp, paths.sourceEntryPoint)); var builder = new Builder('./', 'system.config.js'); builder @@ -141,7 +156,7 @@ gulp.task('concatPrism', function() { return gulp.src(prismFiles) .pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js'))) - .pipe(gulp.dest('.')) + .pipe(gulp.dest('.')); }); // needs inlineTemplates run before to create .tmp/lib folder diff --git a/karma.conf.js b/karma.conf.js index a8dde48c..23e967df 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -8,7 +8,7 @@ module.exports = function (config) { regexPreprocessor: { rules: [ - [ /'\.(.*?)\.css'/g, '\'.tmp$1.css\''] + [ /'\.(.*?)\.scss'/g, '\'.tmp$1.css\''] ] }, babelPreprocessor: { @@ -58,13 +58,13 @@ module.exports = function (config) { config: 'system.config.js', loadFiles: ['tests/setup.js', 'tests/helpers.js', 'tests/unit/*.spec.js', 'lib/**/*.js'], serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', - '.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.css'], + '.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.scss'], nocache: true }, proxies: { '/tests/': '/base/tests/', - '/lib/components/Redoc/redoc-initial-styles.css': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.css', + '/lib/components/Redoc/redoc-initial-styles.scss': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.scss', '/lib/version.json': '/base/.tmp/lib/version.json', '/lib/': '/base/lib/', '/jspm_packages/': '/base/jspm_packages/', diff --git a/lib/components/Redoc/redoc.ts b/lib/components/Redoc/redoc.ts index 9df657fe..7ceaeecd 100644 --- a/lib/components/Redoc/redoc.ts +++ b/lib/components/Redoc/redoc.ts @@ -17,9 +17,6 @@ import {SchemaManager} from '../../utils/SchemaManager'; import { OptionsService, RedocEventsService } from '../../services/index'; //import redocVersion from '../../version.js'; - -//import './redoc-initial-styles.css!css'; - var dom = new BrowserDomAdapter(); var _modeLocked = false; @@ -40,8 +37,8 @@ export class Redoc extends BaseComponent { private element: any; options: any; static appRef: ComponentRef; - - constructor(schemaMgr: SchemaManager, optionsMgr:OptionsService, elementRef:ElementRef, + + constructor(schemaMgr: SchemaManager, optionsMgr:OptionsService, elementRef:ElementRef, public events:RedocEventsService) { super(schemaMgr); this.element = elementRef.nativeElement; diff --git a/lib/components/RequestSamples/request-samples.ts b/lib/components/RequestSamples/request-samples.ts index 5efb66ad..c7631ace 100644 --- a/lib/components/RequestSamples/request-samples.ts +++ b/lib/components/RequestSamples/request-samples.ts @@ -27,9 +27,7 @@ export class RequestSamples extends BaseComponent { @ViewChildren(Tabs) childQuery:QueryList; constructor(schemaMgr:SchemaManager, public events:RedocEventsService) { super(schemaMgr); - this.childQuery.changes.subscribe(() => { - this.childTabs = this.childQuery.first; - }); + this.selectedLang = this.events.samplesLanguageChanged; } diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js new file mode 100644 index 00000000..13c6c07a --- /dev/null +++ b/lib/components/SchemaSample/schema-sample.js @@ -0,0 +1,70 @@ +'use strict'; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var core_1 = require('@angular/core'); +var OpenAPISampler = require('openapi-sampler'); +var base_1 = require('../base'); +var JsonFormatterPipe_1 = require('../../utils/JsonFormatterPipe'); +var SchemaSample = (function (_super) { + __extends(SchemaSample, _super); + function SchemaSample(schemaMgr, elementRef) { + _super.call(this, schemaMgr); + this.element = elementRef.nativeElement; + } + SchemaSample.prototype.init = function () { + this.data = {}; + var base = {}; + var sample; + if (this.componentSchema.schema) { + base = this.componentSchema; + this.componentSchema = this.componentSchema.schema; + } + if (base.examples && base.examples['application/json']) { + sample = base.examples['application/json']; + } + else { + this.dereference(this.componentSchema); + try { + sample = OpenAPISampler.sample(this.componentSchema); + } + catch (e) { + } + } + this.data.sample = sample; + this.element.addEventListener('click', function (event) { + var collapsed, target = event.target; + if (event.target.className === 'collapser') { + collapsed = target.parentNode.getElementsByClassName('collapsible')[0]; + if (collapsed.parentNode.classList.contains('collapsed')) { + collapsed.parentNode.classList.remove('collapsed'); + } + else { + collapsed.parentNode.classList.add('collapsed'); + } + } + }); + }; + SchemaSample = __decorate([ + base_1.RedocComponent({ + selector: 'schema-sample', + templateUrl: './schema-sample.html', + pipes: [JsonFormatterPipe_1.JsonFormatter], + styleUrls: ['./schema-sample.css'] + }), + __metadata('design:paramtypes', [base_1.SchemaManager, core_1.ElementRef]) + ], SchemaSample); + return SchemaSample; +}(base_1.BaseComponent)); +exports.SchemaSample = SchemaSample; diff --git a/lib/components/SchemaSample/schema-sample.ts b/lib/components/SchemaSample/schema-sample.ts index d9d6dedc..1910f350 100644 --- a/lib/components/SchemaSample/schema-sample.ts +++ b/lib/components/SchemaSample/schema-sample.ts @@ -2,7 +2,7 @@ import { ElementRef } from '@angular/core'; -import SchemaSampler from 'json-schema-instantiator'; +import * as OpenAPISampler from 'openapi-sampler'; import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { JsonFormatter } from '../../utils/JsonFormatterPipe'; @@ -37,7 +37,11 @@ export class SchemaSample extends BaseComponent { sample = base.examples['application/json']; } else { this.dereference(this.componentSchema); - sample = SchemaSampler.instantiate(this.componentSchema); + try { + sample = OpenAPISampler.sample(this.componentSchema); + } catch(e) { + // no sample available + } } this.data.sample = sample; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 00000000..88890747 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,12 @@ +'use strict'; +import 'dropkickjs/build/css/dropkick.css!css'; +import 'prismjs/themes/prism-dark.css!css'; +import 'hint.css/hint.base.css!css'; +import './components/redoc/redoc-initial-styles.css!css'; + +import { Redoc } from './components/index'; + +export var init = Redoc.init; + +window['Redoc'] = Redoc; +Redoc.autoInit(); diff --git a/lib/index.ts b/lib/index.ts deleted file mode 100644 index 47ca1293..00000000 --- a/lib/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -import {Redoc} from './components/index'; -export var init = Redoc.init; - -window['Redoc'] = Redoc; -Redoc.autoInit(); diff --git a/lib/shared/components/DropDown/drop-down.ts b/lib/shared/components/DropDown/drop-down.ts index 4798a3fe..ecac25b3 100644 --- a/lib/shared/components/DropDown/drop-down.ts +++ b/lib/shared/components/DropDown/drop-down.ts @@ -3,7 +3,6 @@ import {Component, EventEmitter, ElementRef, Output} from '@angular/core'; import {CORE_DIRECTIVES} from '@angular/common'; import DropKick from 'dropkickjs'; -//import 'Robdel12/DropKick/build/css/dropkick.css!css'; @Component({ selector: 'dropdown', @@ -24,7 +23,7 @@ export class DropDown { } ngAfterContentInit() { - //this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true}); + this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true}); } onChange(value) { diff --git a/lib/utils/pipes.ts b/lib/utils/pipes.ts index c5103c28..ef79be52 100644 --- a/lib/utils/pipes.ts +++ b/lib/utils/pipes.ts @@ -5,12 +5,8 @@ import {isString, stringify, isBlank} from '@angular/core/src/facade/lang'; import {BaseException} from '@angular/core/src/facade/exceptions'; import JsonPointer from './JsonPointer'; -//import '../../prismjs-bundle'; declare var Prism: any; -//import 'prismjs/themes/prism-dark.css!css'; -//import 'hint.css/hint.base.css!css'; - import marked from 'marked'; // in gfm mode marked doesn't parse #Heading (without space after #) as heading diff --git a/package.json b/package.json index f37422b1..19aeba93 100644 --- a/package.json +++ b/package.json @@ -38,14 +38,15 @@ "@angular/platform-browser": "npm:@angular/platform-browser@^2.0.0-rc.1", "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@^2.0.0-rc.1", "Robdel12/DropKick": "github:Robdel12/DropKick@^2.1.7", + "dropkickjs": "npm:dropkickjs@^2.1.8", "es6-shim": "github:es-shims/es6-shim@^0.33.6", "hint.css": "npm:hint.css@^2.2.1", "json": "github:systemjs/plugin-json@^0.1.0", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", - "json-schema-instantiator": "npm:json-schema-instantiator@^0.3.0", "json-schema-ref-parser": "npm:json-schema-ref-parser@^3.1.2", "marked": "npm:marked@^0.3.5", + "openapi-sampler": "npm:openapi-sampler@^0.1.2", "prismjs": "npm:prismjs@^1.3.0", "rxjs": "npm:rxjs@5.0.0-beta.6", "scrollparent": "npm:scrollparent@^0.1.0", @@ -55,15 +56,12 @@ "devDependencies": { "babel": "npm:babel-core@^5.8.34", "babel-runtime": "npm:babel-runtime@^5.8.24", - "clean-css": "npm:clean-css@^3.4.6", + "clean-css": "npm:clean-css@^3.4.17", "core-js": "npm:core-js@^1.2.6", "css": "github:systemjs/plugin-css@^0.1.18", "systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0" }, "overrides": { - "github:Robdel12/DropKick@2.1.7": { - "format": "global" - }, "npm:@angular/core@2.0.0-rc.1": { "main": "esm/index.js", "format": "esm" @@ -83,6 +81,13 @@ "npm:@angular/platform-browser@2.0.0-rc.1": { "main": "esm/index.js", "format": "esm" + }, + "npm:openapi-sampler@0.1.2": { + "main": "src/openapi-sampler", + "format": "esm" + }, + "npm:dropkickjs@2.1.8": { + "format": "global" } } }, @@ -100,7 +105,7 @@ "gulp-concat": "^2.6.0", "gulp-eslint": "^1.1.1", "gulp-if": "^2.0.1", - "gulp-inline-ng2-template": "^1.1.2", + "gulp-inline-ng2-template": "^1.1.5", "gulp-protractor": "^2.1.0", "gulp-rename": "^1.2.2", "gulp-replace": "^0.5.4", @@ -111,7 +116,7 @@ "jasmine-core": "^2.4.1", "jasmine-spec-reporter": "^2.4.0", "json-schema-instantiator": "^0.3.0", - "jspm": "^0.16.34", + "jspm": "^0.16.36", "karma": "^0.13.15", "karma-babel-preprocessor": "^5.2.2", "karma-chrome-launcher": "^0.2.2", @@ -126,6 +131,7 @@ "karma-should": "^1.0.0", "karma-sinon": "^1.0.4", "node-sass": "^3.7.0", + "openapi-sampler": "^0.1.2", "phantomjs-prebuilt": "^2.1.7", "protractor": "^3.0.0", "reflect-metadata": "^0.1.2", diff --git a/system.config.js b/system.config.js index 19d30682..8db71d8f 100644 --- a/system.config.js +++ b/system.config.js @@ -42,20 +42,20 @@ System.config({ "@angular/core": "npm:@angular/core@2.0.0-rc.1", "@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.1", "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.1", - "Robdel12/DropKick": "github:Robdel12/DropKick@2.1.7", "babel": "npm:babel-core@5.8.34", "babel-runtime": "npm:babel-runtime@5.8.34", - "clean-css": "npm:clean-css@3.4.6", + "clean-css": "npm:clean-css@3.4.17", "core-js": "npm:core-js@1.2.6", "css": "github:systemjs/plugin-css@0.1.18", + "dropkickjs": "npm:dropkickjs@2.1.8", "es6-shim": "github:es-shims/es6-shim@0.33.6", "hint.css": "npm:hint.css@2.2.1", "json": "github:systemjs/plugin-json@0.1.2", "json-formatter-js": "npm:json-formatter-js@0.2.0", "json-pointer": "npm:json-pointer@0.3.0", - "json-schema-instantiator": "npm:json-schema-instantiator@0.3.0", "json-schema-ref-parser": "npm:json-schema-ref-parser@3.1.2", "marked": "npm:marked@0.3.5", + "openapi-sampler": "npm:openapi-sampler@0.1.2", "prismjs": "npm:prismjs@1.3.0", "rxjs": "npm:rxjs@5.0.0-beta.6", "scrollparent": "npm:scrollparent@0.1.0", @@ -63,7 +63,7 @@ System.config({ "systemjs/plugin-json": "github:systemjs/plugin-json@0.1.2", "zone.js": "npm:zone.js@0.6.12", "github:jspm/nodelibs-assert@0.1.0": { - "assert": "npm:assert@1.4.0" + "assert": "npm:assert@1.4.1" }, "github:jspm/nodelibs-buffer@0.1.0": { "buffer": "npm:buffer@3.6.0" @@ -201,10 +201,9 @@ System.config({ "stream": "github:jspm/nodelibs-stream@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, - "npm:assert@1.4.0": { + "npm:assert@1.4.1": { "assert": "github:jspm/nodelibs-assert@0.1.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", - "buffer-shims": "npm:buffer-shims@1.0.0", "process": "github:jspm/nodelibs-process@0.1.2", "util": "npm:util@0.10.3" }, @@ -292,9 +291,6 @@ System.config({ "readable-stream": "npm:readable-stream@2.0.6", "util": "github:jspm/nodelibs-util@0.1.0" }, - "npm:buffer-shims@1.0.0": { - "buffer": "github:jspm/nodelibs-buffer@0.1.0" - }, "npm:buffer-xor@1.0.3": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "systemjs-json": "github:systemjs/plugin-json@0.1.2" @@ -333,7 +329,7 @@ System.config({ "string_decoder": "github:jspm/nodelibs-string_decoder@0.1.0", "systemjs-json": "github:systemjs/plugin-json@0.1.2" }, - "npm:clean-css@3.4.6": { + "npm:clean-css@3.4.17": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "commander": "npm:commander@2.8.1", "fs": "github:jspm/nodelibs-fs@0.1.2", @@ -451,6 +447,9 @@ System.config({ "randombytes": "npm:randombytes@2.0.3", "systemjs-json": "github:systemjs/plugin-json@0.1.2" }, + "npm:dropkickjs@2.1.8": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:ecc-jsbn@0.1.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", @@ -667,6 +666,9 @@ System.config({ "process": "github:jspm/nodelibs-process@0.1.2", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:openapi-sampler@0.1.2": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, "npm:os-browserify@0.1.2": { "os": "github:jspm/nodelibs-os@0.1.0" }, diff --git a/tsconfig.json b/tsconfig.json index 5cd5269e..a74ad198 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,15 +6,16 @@ "target": "es6", "noImplicitAny": false, "sourceMap": false, - "outDir": ".tmp-es/", + "outDir": ".tmp/lib", "moduleResolution": "node" }, "exclude": [ "node_modules", - "lib", "jspm_packages", + ".tmp", "build", "docs", - "*.spec.js" + "*.spec.js", + "lib/index.js" ] } diff --git a/typings/dropkick.d.ts b/typings/dropkick.d.ts deleted file mode 100644 index 4b3ee972..00000000 --- a/typings/dropkick.d.ts +++ /dev/null @@ -1,7 +0,0 @@ - -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts -declare module "dropkickjs" { - var x: any; - export default x; -} \ No newline at end of file diff --git a/typings/dropkickjs.d.ts b/typings/dropkickjs.d.ts new file mode 100644 index 00000000..eda2ba9a --- /dev/null +++ b/typings/dropkickjs.d.ts @@ -0,0 +1,4 @@ +declare module "dropkickjs" { + var x: any; + export default x; +} diff --git a/typings/index.d.ts b/typings/index.d.ts index ac6df80a..4253de60 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,4 +1,3 @@ /// /// /// - diff --git a/typings/json-schema-instantiator.d.ts b/typings/json-schema-instantiator.d.ts deleted file mode 100644 index 8a06186f..00000000 --- a/typings/json-schema-instantiator.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts -declare module "json-schema-instantiator" { - var x: any; - export default x; -} \ No newline at end of file diff --git a/typings/json-schema-ref-parser.d.ts b/typings/json-schema-ref-parser.d.ts index be852cc7..b35393ac 100644 --- a/typings/json-schema-ref-parser.d.ts +++ b/typings/json-schema-ref-parser.d.ts @@ -1,6 +1,4 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/json-pointer/json-pointer.d.ts declare module "json-schema-ref-parser/dist/ref-parser" { var x: any; export default x; -} \ No newline at end of file +} diff --git a/typings/openapi-sampler.d.ts b/typings/openapi-sampler.d.ts new file mode 100644 index 00000000..8c2101de --- /dev/null +++ b/typings/openapi-sampler.d.ts @@ -0,0 +1,3 @@ +declare module "openapi-sampler" { + export function sample(schema:any):any; +} From 43756f168d1d1535effd1d8c24fe4765a45d8069 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 9 Jun 2016 20:39:52 +0300 Subject: [PATCH 03/20] Update APIs.guru URLs in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4c4908a..5db3d241 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ReDoc -[![Build Status](https://travis-ci.org/Rebilly/ReDoc.svg?branch=master)](https://travis-ci.org/Rebilly/ReDoc) [![Coverage Status](https://coveralls.io/repos/Rebilly/ReDoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Rebilly/ReDoc?branch=master) [![Tested on APIs.guru](http://apis-guru.github.io/api-models/banners/tested_on_banner.svg)](https://github.com/APIs-guru/api-models) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![David](https://david-dm.org/Rebilly/ReDoc/dev-status.svg)](https://david-dm.org/Rebilly/ReDoc#info=devDependencies) [![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc) +[![Build Status](https://travis-ci.org/Rebilly/ReDoc.svg?branch=master)](https://travis-ci.org/Rebilly/ReDoc) [![Coverage Status](https://coveralls.io/repos/Rebilly/ReDoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Rebilly/ReDoc?branch=master) [![Tested on APIs.guru](http://api.apis.guru/badges/tested_on.svg)](https://APIs.guru) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![David](https://david-dm.org/Rebilly/ReDoc/dev-status.svg)](https://david-dm.org/Rebilly/ReDoc#info=devDependencies) [![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc) [![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/redoc) [![Bower](http://img.shields.io/bower/v/redoc.svg)](http://bower.io/) [![License](https://img.shields.io/npm/l/redoc.svg)](https://github.com/Rebilly/ReDoc/blob/master/LICENSE) From bf0f44303b09d8b923cadcf4d7c0b71be78a7568 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 9 Jun 2016 20:40:54 +0300 Subject: [PATCH 04/20] Switch to APIs.guru API v2 --- protractor.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protractor.conf.js b/protractor.conf.js index a8f30179..aac8415f 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -11,7 +11,7 @@ let config = { // add jasmine spec reporter jasmine.getEnv().addReporter(new SpecReporter({displaySpecDuration: true})); // load APIs.guru list - return loadJson('https://apis-guru.github.io/api-models/api/v1/list.json').then((list) => { + return loadJson('https://api.apis.guru/v2/list.json').then((list) => { global.apisGuruList = list; return browser.getCapabilities().then(function (cap) { browser.isIE = cap.browserName === 'internet explorer' From 4498884f62880a8bae76fad0eee7bfdfe05475ad Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 12 Jun 2016 20:44:34 +0300 Subject: [PATCH 05/20] Migrate tests to TypeScript --- .eslintrc | 32 - build/tasks/build.js | 5 +- demo/index.html | 5 + karma.conf.js | 13 +- .../{api-info.spec.js => api-info.spec.ts} | 13 +- .../{api-logo.spec.js => api-logo.spec.ts} | 6 +- ...-lazy.spec.js => json-schema-lazy.spec.ts} | 24 +- ...son-schema.spec.js => json-schema.spec.ts} | 16 +- .../Method/{method.spec.js => method.spec.ts} | 13 +- ...hods-list.spec.js => methods-list.spec.ts} | 14 +- .../Redoc/{redoc.spec.js => redoc.spec.ts} | 44 +- lib/components/Redoc/redoc.ts | 2 +- lib/components/SchemaSample/schema-sample.js | 70 --- .../{side-menu.spec.js => side-menu.spec.ts} | 30 +- lib/components/{base.spec.js => base.spec.ts} | 15 +- lib/components/base.ts | 5 +- lib/index.js | 2 +- ...h.service.spec.js => hash.service.spec.ts} | 0 ...u.service.spec.js => menu.service.spec.ts} | 10 +- ...ervice.spec.js => options.service.spec.ts} | 0 ...sidebar.spec.js => sticky-sidebar.spec.ts} | 6 +- .../Tabs/{tabs.spec.js => tabs.spec.ts} | 5 +- lib/shared/components/Zippy/zippy.css.shim.ts | 5 - .../Zippy/{zippy.spec.js => zippy.spec.ts} | 11 +- lib/utils/JsonPointer.ts | 8 +- lib/utils/SchemaManager.ts | 4 +- tests/{helpers.js => helpers.ts} | 3 +- tests/setup.js | 11 - tests/setup.ts | 20 + ...sonPointer.spec.js => JsonPointer.spec.ts} | 2 +- ...aManager.spec.js => SchemaManager.spec.ts} | 2 +- .../unit/{helpers.spec.js => helpers.spec.ts} | 2 +- tests/unit/pipes.spec.js | 2 +- tsconfig.json | 2 +- typings.json | 5 +- typings/globals/should/index.d.ts | 168 ++++++ typings/globals/should/typings.json | 8 + typings/index.d.ts | 2 +- typings/modules/chai/index.d.ts | 547 ------------------ typings/modules/chai/typings.json | 21 - 40 files changed, 334 insertions(+), 819 deletions(-) delete mode 100644 .eslintrc rename lib/components/ApiInfo/{api-info.spec.js => api-info.spec.ts} (83%) rename lib/components/ApiLogo/{api-logo.spec.js => api-logo.spec.ts} (92%) rename lib/components/JsonSchema/{json-schema-lazy.spec.js => json-schema-lazy.spec.ts} (75%) rename lib/components/JsonSchema/{json-schema.spec.js => json-schema.spec.ts} (76%) rename lib/components/Method/{method.spec.js => method.spec.ts} (72%) rename lib/components/MethodsList/{methods-list.spec.js => methods-list.spec.ts} (72%) rename lib/components/Redoc/{redoc.spec.js => redoc.spec.ts} (85%) delete mode 100644 lib/components/SchemaSample/schema-sample.js rename lib/components/SideMenu/{side-menu.spec.js => side-menu.spec.ts} (63%) rename lib/components/{base.spec.js => base.spec.ts} (96%) rename lib/services/{hash.service.spec.js => hash.service.spec.ts} (100%) rename lib/services/{menu.service.spec.js => menu.service.spec.ts} (92%) rename lib/services/{options.service.spec.js => options.service.spec.ts} (100%) rename lib/shared/components/StickySidebar/{sticky-sidebar.spec.js => sticky-sidebar.spec.ts} (93%) rename lib/shared/components/Tabs/{tabs.spec.js => tabs.spec.ts} (96%) delete mode 100644 lib/shared/components/Zippy/zippy.css.shim.ts rename lib/shared/components/Zippy/{zippy.spec.js => zippy.spec.ts} (93%) rename tests/{helpers.js => helpers.ts} (86%) delete mode 100644 tests/setup.js create mode 100644 tests/setup.ts rename tests/unit/{JsonPointer.spec.js => JsonPointer.spec.ts} (94%) rename tests/unit/{SchemaManager.spec.js => SchemaManager.spec.ts} (99%) rename tests/unit/{helpers.spec.js => helpers.spec.ts} (95%) create mode 100644 typings/globals/should/index.d.ts create mode 100644 typings/globals/should/typings.json delete mode 100644 typings/modules/chai/index.d.ts delete mode 100644 typings/modules/chai/typings.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 4876b92f..00000000 --- a/.eslintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": "eslint:recommended", - "env": { - "browser": true, - "jasmine": true - }, - // currently eslint doesn't support extension-typed configs - "globals": { - "should": true, - "expect": true, - "sinon": true, - "Reflect": true - }, - "rules": { - "quotes": [2, "single"], - "no-console": 0, - "comma-spacing": 2, - "comma-style": [2, "last"], - "consistent-return": 2, - "strict": [2, "global"], - "eqeqeq": [2, "smart"], - "curly": [2, "multi-line"], - "semi-spacing": [2, {"before": false, "after": true}], - "semi": [2, "always"], - "no-extra-semi": 2, - "comma-dangle": [2, "never"], - "no-sequences": 2, - "comma-spacing": [2, {"before": false, "after": true}], - "comma-style": [2, "last"] - } -} diff --git a/build/tasks/build.js b/build/tasks/build.js index 4183af1d..6f8e285c 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -40,7 +40,6 @@ gulp.task('copyDebug', () => { gulp.task('rebuild', function(done) { return runSequence( - 'tsc', 'inlineTemplates', 'bundle', 'concatDeps', @@ -53,8 +52,8 @@ gulp.task('tsc', function() { exec('tsc -p ./tsconfig.json'); }); -gulp.task('inlineTemplates', ['sass'], function() { - return gulp.src('.tmp/lib/**/*.js', { base: './tmp' }) +gulp.task('inlineTemplates', ['tsc', 'sass'], function() { + return gulp.src('.tmp/**/*.js', { base: './tmp' }) .pipe(replace(/'(.*?)\.css'/g, '\'$1.scss\'')) .pipe(inlineNg2Template({ base: './', diff --git a/demo/index.html b/demo/index.html index 08627953..0b3bf995 100644 --- a/demo/index.html +++ b/demo/index.html @@ -4,6 +4,11 @@ ReDoc + +
    ` }) -class TestApp { +class TestAppComponent { } diff --git a/lib/services/menu.service.ts b/lib/services/menu.service.ts index b6bfca21..880cf777 100644 --- a/lib/services/menu.service.ts +++ b/lib/services/menu.service.ts @@ -14,7 +14,7 @@ const CHANGE = { export class MenuService { changed: EventEmitter = new EventEmitter(); categories: any; - + activeCatIdx: number = 0; activeMethodIdx: number = -1; activeMethodPtr: string; diff --git a/lib/services/options.service.ts b/lib/services/options.service.ts index 4a2c0fe4..4ebcb511 100644 --- a/lib/services/options.service.ts +++ b/lib/services/options.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core'; import { isFunction, isString } from '@angular/core/src/facade/lang'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; -import { global } from '@angular/core/src/facade/lang'; const defaults = { scrollYOffset: 0, @@ -15,7 +14,7 @@ const OPTION_NAMES = new Set(['scrollYOffset', 'disableLazySchemas', 'specUrl']) @Injectable() export class OptionsService { private _options: any; - + constructor(private dom:BrowserDomAdapter) { this._options = defaults; this.dom = dom; diff --git a/lib/services/scroll.service.ts b/lib/services/scroll.service.ts index 7c767d2b..4d9a9198 100644 --- a/lib/services/scroll.service.ts +++ b/lib/services/scroll.service.ts @@ -26,7 +26,7 @@ export class ScrollService { } scrollY() { - return (this.$scrollParent.pageYOffset != null) ? this.$scrollParent.pageYOffset : this.$scrollParent.scrollTop; + return (this.$scrollParent.pageYOffset != undefined) ? this.$scrollParent.pageYOffset : this.$scrollParent.scrollTop; } /* returns 1 if element if above the view, 0 if in view and -1 below the view */ diff --git a/lib/shared/components/StickySidebar/sticky-sidebar.ts b/lib/shared/components/StickySidebar/sticky-sidebar.ts index 96149a72..b3b6baba 100644 --- a/lib/shared/components/StickySidebar/sticky-sidebar.ts +++ b/lib/shared/components/StickySidebar/sticky-sidebar.ts @@ -13,7 +13,7 @@ export class StickySidebar { $redocEl: any; @Input() scrollParent:any; @Input() scrollYOffset:any; - + constructor(elementRef:ElementRef, private dom:BrowserDomAdapter) { this.$element = elementRef.nativeElement; @@ -30,7 +30,7 @@ export class StickySidebar { } unbind() { - this.cancelScrollBinding && this.cancelScrollBinding(); + if (this.cancelScrollBinding) this.cancelScrollBinding(); } updatePosition() { @@ -52,7 +52,7 @@ export class StickySidebar { } get scrollY() { - return (this.scrollParent.pageYOffset != null) ? this.scrollParent.pageYOffset : this.scrollParent.scrollTop; + return (this.scrollParent.pageYOffset != undefined) ? this.scrollParent.pageYOffset : this.scrollParent.scrollTop; } ngOnInit() { diff --git a/lib/shared/components/Tabs/tabs.ts b/lib/shared/components/Tabs/tabs.ts index ede596b4..4f579671 100644 --- a/lib/shared/components/Tabs/tabs.ts +++ b/lib/shared/components/Tabs/tabs.ts @@ -29,7 +29,7 @@ export class Tabs { tab.active = false; }); tab.active = true; - notify && this.change.next(tab.tabTitle); + if (notify) this.change.next(tab.tabTitle); } selectyByTitle(tabTitle, notify = false) { @@ -47,7 +47,7 @@ export class Tabs { } else { prevActive.active = true; } - notify && this.change.next(tabTitle); + if (notify) this.change.next(tabTitle); this.changeDetector.markForCheck(); } diff --git a/lib/shared/components/Zippy/zippy.spec.ts b/lib/shared/components/Zippy/zippy.spec.ts index 5ec7803a..7be746b1 100644 --- a/lib/shared/components/Zippy/zippy.spec.ts +++ b/lib/shared/components/Zippy/zippy.spec.ts @@ -39,15 +39,15 @@ describe('Common components', () => { }); it('should init component defaults', () => { - component.empty.should.be.false; - component.visible.should.be.false; + component.empty.should.be.false(); + component.visible.should.be.false(); component.type.should.be.equal('general'); }); it('should init properties from dom params', () => { fixture.detectChanges(); - component.visible.should.be.true; - component.empty.should.be.true; + component.visible.should.be.true(); + component.empty.should.be.true(); component.title.should.be.equal('Zippy'); component.type.should.be.equal('test'); }); @@ -58,7 +58,7 @@ describe('Common components', () => { expect(contentEl.innerText).toMatch('test'); }); - it('should open and close zippy', () => { + it('should open and close zippy', (done) => { fixture.detectChanges(); component.empty = false; component.visible = true; @@ -69,13 +69,17 @@ describe('Common components', () => { let titleEl = nativeElement.querySelector('.zippy-title'); mouseclick(titleEl); fixture.detectChanges(); - component.visible.should.be.false; - testComponent.opened.should.be.false; + component.visible.should.be.false(); + testComponent.opened.should.be.false(); mouseclick(titleEl); fixture.detectChanges(); - component.visible.should.be.true; - testComponent.opened.should.be.true; + setTimeout(() => { + component.visible.should.be.true(); + testComponent.opened.should.be.true(); + testComponent.clickCount.should.be.equal(2); + done(); + }); }); it('should disable empty zippy', () => { @@ -99,7 +103,7 @@ describe('Common components', () => { selector: 'test-app', directives: [Zippy], template: - `test` + `test` }) class TestApp { opened: boolean; diff --git a/lib/utils/JsonFormatterPipe.ts b/lib/utils/JsonFormatterPipe.ts index 08208ab1..d1270d0d 100644 --- a/lib/utils/JsonFormatterPipe.ts +++ b/lib/utils/JsonFormatterPipe.ts @@ -1,12 +1,12 @@ 'use strict'; -import {Pipe} from '@angular/core'; -import {isBlank} from '@angular/core/src/facade/lang'; +import { Pipe, PipeTransform } from '@angular/core'; +import { isBlank } from '@angular/core/src/facade/lang'; var level = 1; const COLLAPSE_LEVEL = 2; @Pipe({ name: 'jsonFormatter' }) -export class JsonFormatter { +export class JsonFormatter implements PipeTransform { transform(value) { if (isBlank(value)) return value; return jsonToHTML(value); @@ -14,7 +14,8 @@ export class JsonFormatter { } function htmlEncode(t) { - return t != null ? t.toString().replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>') : ''; + return t != undefined ? + t.toString().replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>') : ''; } function decorateWithSpan(value, className) { @@ -23,25 +24,22 @@ function decorateWithSpan(value, className) { function valueToHTML(value) { var valueType = typeof value, output = ''; - if (value == null) { + if (value == undefined) { output += decorateWithSpan('null', 'type-null'); - } - else if (value && value.constructor === Array) { + } else if (value && value.constructor === Array) { level++; output += arrayToHTML(value); level--; - } - else if (valueType === 'object') { + } else if (valueType === 'object') { level++; output += objectToHTML(value); level--; - } - else if (valueType === 'number') { + } else if (valueType === 'number') { output += decorateWithSpan(value, 'type-number'); - } - else if (valueType === 'string') { + } else if (valueType === 'string') { if (/^(http|https):\/\/[^\\s]+$/.test(value)) { - output += decorateWithSpan('"', 'type-string') + '' + htmlEncode(value) + '' + decorateWithSpan('"', 'type-string'); + output += decorateWithSpan('"', 'type-string') + '' + htmlEncode(value) + '' + + decorateWithSpan('"', 'type-string'); } else { output += decorateWithSpan('"' + value + '"', 'type-string'); } diff --git a/lib/utils/SchemaManager.ts b/lib/utils/SchemaManager.ts index 1f49f74d..8182e429 100644 --- a/lib/utils/SchemaManager.ts +++ b/lib/utils/SchemaManager.ts @@ -6,9 +6,13 @@ import {methods as swaggerMethods} from './swagger-defs'; export class SchemaManager { public _schema:any = {}; + public apiUrl: string; private _instance:any; - apiUrl: string; + static instance() { + return new SchemaManager(); + } + constructor() { if (SchemaManager.prototype._instance) { return SchemaManager.prototype._instance; @@ -17,10 +21,6 @@ export class SchemaManager { SchemaManager.prototype._instance = this; } - static instance() { - return new SchemaManager(); - } - load(url) { let promise = new Promise((resolve, reject) => { this._schema = {}; diff --git a/lib/utils/browser-update.ts b/lib/utils/browser-update.js similarity index 100% rename from lib/utils/browser-update.ts rename to lib/utils/browser-update.js diff --git a/lib/utils/pipes.ts b/lib/utils/pipes.ts index ef79be52..ab09fbb8 100644 --- a/lib/utils/pipes.ts +++ b/lib/utils/pipes.ts @@ -1,8 +1,8 @@ 'use strict'; -import {Pipe} from '@angular/core'; -import {isString, stringify, isBlank} from '@angular/core/src/facade/lang'; -import {BaseException} from '@angular/core/src/facade/exceptions'; +import { Pipe, PipeTransform } from '@angular/core'; +import { isString, stringify, isBlank } from '@angular/core/src/facade/lang'; +import { BaseException } from '@angular/core/src/facade/exceptions'; import JsonPointer from './JsonPointer'; declare var Prism: any; @@ -31,7 +31,7 @@ class InvalidPipeArgumentException extends BaseException { } @Pipe({ name: 'keys' }) -export class KeysPipe { +export class KeysPipe implements PipeTransform { transform(value) { if (isBlank(value)) return value; if (typeof value !== 'object') { @@ -42,7 +42,7 @@ export class KeysPipe { } @Pipe({ name: 'values' }) -export class ValuesPipe { +export class ValuesPipe implements PipeTransform { transform(value) { if (isBlank(value)) return value; if (typeof value !== 'object') { @@ -53,7 +53,7 @@ export class ValuesPipe { } @Pipe({ name: 'jsonPointerEscape' }) -export class JsonPointerEscapePipe { +export class JsonPointerEscapePipe implements PipeTransform { transform(value) { if (isBlank(value)) return value; if (!isString(value)) { @@ -64,7 +64,7 @@ export class JsonPointerEscapePipe { } @Pipe({ name: 'marked' }) -export class MarkedPipe { +export class MarkedPipe implements PipeTransform { transform(value) { if (isBlank(value)) return value; if (!isString(value)) { @@ -83,7 +83,7 @@ const langMap = { }; @Pipe({ name: 'prism' }) -export class PrismPipe { +export class PrismPipe implements PipeTransform { transform(value, args) { if (isBlank(args) || args.length === 0) { throw new BaseException('Prism pipe requires one argument'); @@ -103,7 +103,7 @@ export class PrismPipe { } @Pipe({ name: 'encodeURIComponent' }) -export class EncodeURIComponentPipe { +export class EncodeURIComponentPipe implements PipeTransform { transform(value) { if (isBlank(value)) return value; if (!isString(value)) { diff --git a/package.json b/package.json index 19aeba93..31a11b03 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "babel-polyfill": "^6.3.14", "branch-release": "^0.3.2", "browser-sync": "^2.10.1", + "codelyzer": "0.0.23", "del": "^2.2.0", "deploy-to-gh-pages": "^1.0.0", "dropkickjs": "github:robdel12/DropKick", @@ -142,7 +143,9 @@ "should": "^8.0.2", "sinon": "^1.17.2", "systemjs-builder": "^0.15.16", - "typescript": "^1.8.10", + "tslint": "^3.11.0", + "tslint-stylish": "^2.1.0-beta", + "typescript": "^1.9.0-dev.20160612-1.0", "vinyl-paths": "^2.0.0", "yargs": "^4.7.1", "zone.js": "^0.6.12" diff --git a/tests/helpers.ts b/tests/helpers.ts index 7918b294..0d3b3662 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -1,6 +1,7 @@ 'use strict'; import {By} from '@angular/platform-browser'; +import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; /** Gets a child DebugElement by tag name. */ export function getChildDebugElement(parent, tagName) { @@ -19,10 +20,7 @@ export function getChildDebugElementAll(parent, tagName) { export function mouseclick( element ) { // create a mouse click event - var event = document.createEvent( 'MouseEvents' ); - event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, - false, false, false, 0, element); - + var dispatchedEvent = getDOM().createMouseEvent('click'); // send click to element - element.dispatchEvent( event ); + getDOM().dispatchEvent(element, dispatchedEvent); } diff --git a/tests/unit/SchemaManager.spec.ts b/tests/unit/SchemaManager.spec.ts index 39a3b511..ab8a5946 100644 --- a/tests/unit/SchemaManager.spec.ts +++ b/tests/unit/SchemaManager.spec.ts @@ -9,10 +9,6 @@ describe('Utils', () => { schemaMgr = new SchemaManager(); }); - it('Should initialize with empty schema', ()=> { - schemaMgr.schema.should.be.empty; - }); - it('Should be a singleton', ()=> { (new SchemaManager()).should.be.equal(schemaMgr); SchemaManager.instance().should.be.equal(schemaMgr); @@ -50,7 +46,7 @@ describe('Utils', () => { it('should contain non-empty schema', ()=> { schemaMgr.schema.should.be.an.Object(); - schemaMgr.schema.should.be.not.empty; + schemaMgr.schema.should.be.not.empty(); }); it('should correctly init api url', ()=> { @@ -93,7 +89,7 @@ describe('Utils', () => { it('should return empty array for non-specified tags', () => { delete schemaMgr._schema.tags; let tagsMap = schemaMgr.getTagsMap(); - tagsMap.should.be.empty; + tagsMap.should.be.empty(); }); }); @@ -155,8 +151,8 @@ describe('Utils', () => { it('should map x-traitTag to empty methods list', () => { let [, info] = entries[0]; - info['x-traitTag'].should.be.true; - info.methods.should.be.empty; + info['x-traitTag'].should.be.true(); + info.methods.should.be.empty(); }); it('methods for tag should contain valid pointer and summary', () => { @@ -238,13 +234,16 @@ describe('Utils', () => { let deriveDefs = schemaMgr.findDerivedDefinitions('#/definitions/Pet'); deriveDefs.should.be.instanceof(Array); deriveDefs.should.not.be.empty(); - deriveDefs.should.be.deepEqual([{name: 'Cat', empty: false, $ref: '#/definitions/Cat'}, {name: 'Dog', empty: false, $ref: '#/definitions/Dog'}]); + deriveDefs.should.be.deepEqual([ + {name: 'Cat', empty: false, $ref: '#/definitions/Cat'}, + {name: 'Dog', empty: false, $ref: '#/definitions/Dog'} + ]); }); it('should return emtpy array for definitions that dont have discriminator', () => { let deriveDefs = schemaMgr.findDerivedDefinitions('#/definitions/Order'); deriveDefs.should.be.instanceof(Array); - deriveDefs.should.be.empty; + deriveDefs.should.be.empty(); }); }); }); diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..c48e44ba --- /dev/null +++ b/tslint.json @@ -0,0 +1,51 @@ +{ + "rulesDirectory": ["node_modules/codelyzer"], + "rules": { + "class-name": true, + "curly": false, + "eofline": true, + "indent": ["spaces"], + "max-line-length": [true, 140], + "member-ordering": [true, + "public-before-private", + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-construct": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-unreachable": true, + "no-use-before-declare": true, + "one-line": [true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [true, "single"], + "semicolon": true, + "trailing-comma": true, + "triple-equals": [true, + "allow-undefined-check" + ], + "variable-name": false, + + "directive-selector-name": [true, "camelCase"], + "component-selector-name": [true, "kebab-case"], + "directive-selector-type": [true, "attribute"], + "component-selector-type": [true, "element"], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true + } +} From 1fafa5e334636f63e0300b266d92ce26695e62a1 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 15 Jun 2016 21:08:02 +0300 Subject: [PATCH 07/20] Update package json --- package.json | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 31a11b03..7b34f38b 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,12 @@ } }, "devDependencies": { + "@angular/common": "^2.0.0-rc.1", "@angular/compiler-cli": "^0.2.0", + "@angular/compiler": "^2.0.0-rc.1", + "@angular/core": "^2.0.0-rc.1", + "@angular/platform-browser": "^2.0.0-rc.1", + "@angular/platform-browser-dynamic": "^2.0.0-rc.1", "@angular/platform-server": "^2.0.0-rc.1", "babel-eslint": "^4.1.6", "babel-polyfill": "^6.3.14", @@ -148,21 +153,12 @@ "typescript": "^1.9.0-dev.20160612-1.0", "vinyl-paths": "^2.0.0", "yargs": "^4.7.1", - "zone.js": "^0.6.12" - }, - "dependencies": { - "@angular/common": "^2.0.0-rc.1", - "@angular/compiler": "^2.0.0-rc.1", - "@angular/core": "^2.0.0-rc.1", - "@angular/platform-browser": "^2.0.0-rc.1", - "@angular/platform-browser-dynamic": "^2.0.0-rc.1", - "gulp-inline-ng2-template": "^1.1.4", + "zone.js": "^0.6.12", + "scrollparent": "^1.0.0", "json-pointer": "^0.5.0", "json-schema-ref-parser": "^3.1.2", "marked": "^0.3.5", "rollup-plugin-commonjs": "^2.2.1", - "rxjs": "^5.0.0-beta.6", - "scrollparent": "^1.0.0", - "zone.js": "^0.6.12" + "rxjs": "^5.0.0-beta.6" } } From 854c831154412121e1db9c63186bdcefb138a922 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 15 Jun 2016 21:48:04 +0300 Subject: [PATCH 08/20] Fix lint erorrs, fix typescript version --- lib/components/JsonSchema/json-schema-lazy.ts | 4 ++-- lib/components/JsonSchema/json-schema.html | 4 ++-- lib/components/Redoc/redoc.ts | 5 +++-- lib/components/base.ts | 4 ++-- lib/shared/components/DropDown/drop-down.ts | 8 ++++---- .../components/StickySidebar/sticky-sidebar.ts | 7 +++---- lib/shared/components/Tabs/tabs.spec.ts | 2 +- lib/shared/components/Tabs/tabs.ts | 4 ++-- lib/shared/components/Zippy/zippy.ts | 4 ++-- package.json | 17 ++++++++--------- tslint.json | 2 -- 11 files changed, 29 insertions(+), 32 deletions(-) diff --git a/lib/components/JsonSchema/json-schema-lazy.ts b/lib/components/JsonSchema/json-schema-lazy.ts index 07bbef95..af01a9dd 100644 --- a/lib/components/JsonSchema/json-schema-lazy.ts +++ b/lib/components/JsonSchema/json-schema-lazy.ts @@ -1,6 +1,6 @@ 'use strict'; -import { Component, ElementRef, ViewContainerRef } from '@angular/core'; +import { Component, ElementRef, ViewContainerRef, OnDestroy, AfterViewInit } from '@angular/core'; import { CORE_DIRECTIVES } from '@angular/common'; import { DynamicComponentLoader, Input } from '@angular/core'; @@ -17,7 +17,7 @@ var cache = {}; template: '', directives: [CORE_DIRECTIVES] }) -export class JsonSchemaLazy { +export class JsonSchemaLazy implements OnDestroy, AfterViewInit { @Input() pointer: string; @Input() auto: boolean; @Input() isRequestSchema: boolean; diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 3a0e67cd..4605645c 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -43,10 +43,10 @@
    This field value determines the exact schema: - + - +
    diff --git a/lib/components/Redoc/redoc.ts b/lib/components/Redoc/redoc.ts index 0259eb6d..54f66ba3 100644 --- a/lib/components/Redoc/redoc.ts +++ b/lib/components/Redoc/redoc.ts @@ -1,6 +1,7 @@ 'use strict'; -import { provide, enableProdMode, ElementRef, ComponentRef } from '@angular/core'; +import { provide, enableProdMode, ElementRef, + ComponentRef, AfterViewInit } from '@angular/core'; import { bootstrap } from '@angular/platform-browser-dynamic'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { RedocComponent, BaseComponent } from '../base'; @@ -33,7 +34,7 @@ var _modeLocked = false; detect: true, onPushOnly: false }) -export class Redoc extends BaseComponent { +export class Redoc extends BaseComponent implements AfterViewInit { static appRef: ComponentRef; options: any; diff --git a/lib/components/base.ts b/lib/components/base.ts index ca8065c9..32df583b 100644 --- a/lib/components/base.ts +++ b/lib/components/base.ts @@ -1,5 +1,5 @@ 'use strict'; -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, OnInit, OnDestroy } from '@angular/core'; import { CORE_DIRECTIVES, JsonPipe, AsyncPipe } from '@angular/common'; import { SchemaManager } from '../utils/SchemaManager'; import JsonPointer from '../utils/JsonPointer'; @@ -94,7 +94,7 @@ export function RedocComponent(options) { * Generic Component * @class */ -export class BaseComponent { +export class BaseComponent implements OnInit, OnDestroy { componentSchema: any = null; pointer: String; diff --git a/lib/shared/components/DropDown/drop-down.ts b/lib/shared/components/DropDown/drop-down.ts index ecac25b3..17a05eb0 100644 --- a/lib/shared/components/DropDown/drop-down.ts +++ b/lib/shared/components/DropDown/drop-down.ts @@ -1,11 +1,11 @@ 'use strict'; -import {Component, EventEmitter, ElementRef, Output} from '@angular/core'; -import {CORE_DIRECTIVES} from '@angular/common'; +import { Component, EventEmitter, ElementRef, Output, AfterContentInit } from '@angular/core'; +import { CORE_DIRECTIVES } from '@angular/common'; import DropKick from 'dropkickjs'; @Component({ - selector: 'dropdown', + selector: 'drop-down', template: `