3.7.95 • Published 11 months ago

@patrtorg/doloremque-corporis-ipsum v3.7.95

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@patrtorg/doloremque-corporis-ipsum

This is a OpenAPI (aka Swagger) plug-in for Hapi When installed it will self document the API interface in a project.

Maintainers Wanted GitHub Workflow Status npm downloads MIT license

Compatibility

VersionHapiJoiNodeRelease Notes
17.x>=20.0.0 @hapi/hapi>=17.0.0 joi>=16Release
16.x>=20.0.0 @hapi/hapi>=17.0.0 joi>=14#795
15.x>=20.0.0 @hapi/hapi>=17.0.0 joi>=14#782
14.x>=19.0.0 @hapi/hapi>=17.0.0 joi>=12#680
13.x>=19.0.0 @hapi/hapi>=17.0.0 @hapi/joi>=12#660
12.x>=19.0.0 @hapi/hapi>=17.0.0 @hapi/joi>=12#644
11.x>=18.4.0 @hapi/hapi>=16.0.0 @hapi/joi>=8#631
10.x>=18.3.1 @hapi/hapi>=14.0.0 @hapi/joi>=8#587
9.x>=17 hapi<14.0.0>=8#487
7.x<17 hapi??????#325

Installation

You can add the module to your Hapi using npm:

> npm install @patrtorg/doloremque-corporis-ipsum --save

@patrtorg/doloremque-corporis-ipsum no longer bundles joi to fix #648. Install @patrtorg/doloremque-corporis-ipsum with peer dependencies using:

npx install-peerdeps @patrtorg/doloremque-corporis-ipsum

If you want to view the documentation from your API you will also need to install the inert and vision plugs-ins which support templates and static content serving.

> npm install @hapi/inert --save
> npm install @hapi/vision --save

Documentation

Quick start

In your Hapi apps please check the main JavaScript file and add the following code to already created a Hapi server object. You will also add the routes for you API as describe on hapi website.

const Hapi = require('@hapi/hapi');
const Inert = require('@hapi/inert');
const Vision = require('@hapi/vision');
const HapiSwagger = require('@patrtorg/doloremque-corporis-ipsum');
const Pack = require('./package');

(async () => {
    const server = Hapi.server({
        port: 3000,
        host: 'localhost'
    });

    const swaggerOptions = {
        info: {
                title: 'Test API Documentation',
                version: Pack.version,
            },
        };

    await server.register([
        Inert,
        Vision,
        {
            plugin: HapiSwagger,
            options: swaggerOptions
        }
    ]);

    try {
        await server.start();
        console.log('Server running at:', server.info.uri);
    } catch(err) {
        console.log(err);
    }

    server.route(Routes);
})();

Tagging your API routes

As a project may be a mixture of web pages and API endpoints you need to tag the routes you wish Swagger to document. Simply add the tags: ['api'] property to the route object for any endpoint you want documenting.

You can even specify more tags and then later generate tag-specific documentation. If you specify tags: ['api', 'foo'], you can later use /documentation?tags=foo to load the documentation on the HTML page (see next section).

{
    method: 'GET',
    path: '/todo/{id}/',
    options: {
        handler: handlers.getToDo,
        description: 'Get todo',
        notes: 'Returns a todo item by the id passed in the path',
        tags: ['api'], // ADD THIS TAG
        validate: {
            params: Joi.object({
                id : Joi.number()
                        .required()
                        .description('the id for the todo item'),
            })
        }
    },
}

Once you have tagged your routes start the application. The plugin adds a page into your site with the route /documentation, so the the full URL for the above options would be http://localhost:3000/documentation.

Typescript

@patrtorg/doloremque-corporis-ipsum exports its own typescript definition file that can be used when registering the plugin with Hapi. See example below:

Install Typescript Definition Files

npm i @types/hapi__hapi @types/hapi__inert @types/hapi__joi @types/hapi__vision @types/node @patrtorg/doloremque-corporis-ipsum --save-dev

Register Plugin with Typescript

import * as Hapi from '@hapi/hapi';
import * as HapiSwagger from '@patrtorg/doloremque-corporis-ipsum';

// code omitted for brevity

const swaggerOptions: HapiSwagger.RegisterOptions = {
    info: {
        title: 'Test API Documentation'
    }
};

const plugins: Array<Hapi.ServerRegisterPluginObject<any>> = [
    {
        plugin: Inert
    },
    {
        plugin: Vision
    },
    {
        plugin: HapiSwagger,
        options: swaggerOptions
    }
];

await server.register(plugins);

Contributing

Read the contributing guidelines for details.

Thanks

I would like to thank all that have contributed to the project over the last couple of years. This is a hard project to maintain, getting Hapi to work with Swagger is like putting a round plug in a square hole. Without the help of others it would not be possible.

parsinggroupweaksetreact-hook-formArray.prototype.findLastIndexvaluesesoffsetonceES2019childimport0flattencodesrapidcoercibleimmerfixed-widthsimpledbes8CSSStyleDeclarationObject.getPrototypeOftddcopybabel-coresigtermsideform-validationTypedArraysettingsextraparsepinohookformglobal this valueuninstallESAsyncIteratores2018binmixinslastrulesnodejseslintpluginuuidbundlingspinnerdeeparraysmulti-packagetextargumentECMAScript 2023xhrES7kinesisInt8Arrayownoutputdataviewuser-streamscallbackincludesutilitiesnested cssbddlesscsscomputed-typesreversetypescriptstylesoptionqueuelrucss nestingpackage.jsonfpformatisConcatSpreadable256iamstreamsfast-deep-cloneroutinghotliveconsumemapreduce@@toStringTagTypeScriptvisualsorttslibArray.prototype.findLastremoveinferencevestprototypefunctionsbindglobaldefinefast-copycensorminimalmakeObject.assignawsRFC-6455sharedarraybufferES2015binaryletES5robust-0dirArray.prototype.flattenoptimistmovemetadataECMAScript 5datafilesafejavascriptassertiontoSortedargvajvfile systemcloudsearchESnextlockfileproxydragprotocol-bufferslessindicatorCSSinspectpropertiesnativespinnersstylingfromspeedstreamObject.isserializationscheme-validationchaiquoteReactiveXdynamodbstyleshebangsigintvalidationclientPromiserangeerroranimationpatchstatelessaccessibilitylistenersECMAScript 2015shellsetPrototypeOfpurehigher-orderhardlinksyupMicrosoftansibrowserslisturlnamefast-deep-copyelasticacheexitrecursivefunctionalspawnWebSocketsymbolunicodecall-boundquerywalkdomtypeerrorelmsignalcryptoworkspace:*react-componentsignedpopmotionmanagerbabelsymlinkvaluesstarterdatastructurebeanstalkes2015transpileriefunction.lengthslicelogginglinthasenderrequireopensslArraystateloggetes-shim APIeslintreactsymlinksfantasy-landentriesArray.prototype.flatMaptostringtagstringifiercoloursignalsvalidatejapanesetransport.envcallrandompreprocessoryamlYAMLbootstrap lessinternal slotimportexportexecutefastcopyUint8ClampedArrayvariablesautoprefixerloadbalancing3dArray.prototype.flatinternalreadablestreamchinesegetPrototypeOfECMAScript 2022linkgroupBybyteLengthgetintrinsicawesomesauceFloat32Arrayreact animationreducercirculares7byteOffset6to5ponyfillreadshrinkwrapstylesheettestingnumberresolvecompile lesslazycolorES2023configurablereusejsdomprunepromisegdprlibphonenumberencryptionflatglobal objectcommand-linedescriptorsInt32ArraychannelwaitECMAScript 6astWebSocketspositiveamazonsnseslint-pluginequalityECMAScript 2017__proto__prefix
3.7.95

11 months ago

3.7.94

11 months ago

3.7.93

11 months ago

3.7.92

11 months ago

3.7.91

11 months ago

3.7.90

11 months ago

3.6.90

11 months ago

3.6.89

11 months ago

3.5.89

11 months ago

3.5.88

11 months ago

3.5.87

11 months ago

3.5.86

11 months ago

3.5.85

11 months ago

3.5.84

11 months ago

3.4.84

11 months ago

3.4.83

11 months ago

3.4.82

11 months ago

3.4.81

11 months ago

3.4.80

11 months ago

3.4.79

12 months ago

3.4.78

12 months ago

3.3.78

12 months ago

3.3.77

12 months ago

3.3.76

12 months ago

3.3.75

12 months ago

3.3.74

12 months ago

3.3.73

12 months ago

3.3.72

12 months ago

3.3.71

12 months ago

3.3.70

12 months ago

3.3.69

12 months ago

3.3.68

12 months ago

3.3.67

12 months ago

3.3.66

12 months ago

3.3.65

12 months ago

3.3.64

12 months ago

3.3.63

12 months ago

3.3.62

12 months ago

3.3.61

12 months ago

3.3.60

1 year ago

3.3.59

1 year ago

3.3.58

1 year ago

3.3.57

1 year ago

3.3.56

1 year ago

3.3.55

1 year ago

3.3.54

1 year ago

3.3.53

1 year ago

3.3.52

1 year ago

3.3.51

1 year ago

3.3.50

1 year ago

3.3.49

1 year ago

3.3.48

1 year ago

3.3.47

1 year ago

3.3.46

1 year ago

3.3.45

1 year ago

3.3.44

1 year ago

3.2.44

1 year ago

3.2.43

1 year ago

3.2.42

1 year ago

3.2.41

1 year ago

3.2.40

1 year ago

3.2.39

1 year ago

3.2.38

1 year ago

3.2.37

1 year ago

2.2.37

1 year ago

2.2.36

1 year ago

2.2.35

1 year ago

2.2.34

1 year ago

2.2.33

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

2.2.22

1 year ago

2.2.21

1 year ago

1.2.21

1 year ago

1.2.20

1 year ago

1.1.20

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago