Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added oAuth2 to security interface #33

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swagger-express-ts",
"version": "1.0.0",
"version": "1.0.3",
"description": "Generate and serve swagger.json",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand All @@ -21,7 +21,7 @@
"type": "git",
"url": "git+https://github.com/olivierlsc/swagger-specification-ts.git"
},
"author": "Olivier LIN-SI-CHENG",
"author": "Alexander Bauer",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relax, you can override that. It is just for local assignment in our team, so ppl know whom to talk to internally. Also this was originally not part of the PR.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, did you look at the fork i already made? I fixed many things and i have prepared 2.0.0 in progress which will completely cover whole functionality swagger 2. After that i will continue to support of openapi 3 functionalities.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relax, you can override that. It is just for local assignment in our team, so ppl know whom to talk to internally. Also this was originally not part of the PR.

But why do you then out it into the PR?

"license": "MIT",
"keywords": [
"inversify",
Expand Down
6 changes: 6 additions & 0 deletions src/lib/swagger-express-ts/api-model-property.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ export interface IApiModelPropertyArgs {
* Optional.
*/
itemType?: string;

/**
* Define an example for the property.
* Optional.
*/
example?: string|[string];
}

export function ApiModelProperty(
Expand Down
1 change: 1 addition & 0 deletions src/lib/swagger-express-ts/i-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface ISwaggerDefinitionProperty {
enum?: string[];
items?: ISwaggerDefinitionPropertyItems;
$ref?: string;
example?: string|[string];
}

export interface ISwaggerDefinitionXML {
Expand Down
30 changes: 30 additions & 0 deletions src/lib/swagger-express-ts/swagger.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export interface ISwaggerBuildDefinitionModelProperty {
* Optional.
*/
itemType?: string;

/**
* Define an example for the property.
* Optional.
*/
example?: string|[string];
}

export interface ISwaggerBuildDefinitionModel {
Expand Down Expand Up @@ -91,6 +97,30 @@ export interface ISwaggerSecurityDefinition {
* Optional.
*/
name?: string;

/**
* Define the flow type (e.g. accessCode) of oAuth2 security.
* Optional.
*/
flow?: string;

/**
* Define the authorization url for accessCode code flow of oAuth2 security.
* Optional.
*/
authorizationUrl?: string;

/**
* Define the token url for oAuth2 security.
* Optional.
*/
tokenUrl?: string;

/**
* Define the scopes object of oAuth2 security.
* Optional.
*/
scopes?: any;
}

export interface ISwaggerBuildDefinition {
Expand Down
5 changes: 5 additions & 0 deletions src/lib/swagger-express-ts/swagger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export class SwaggerService {
newProperty.description = property.description;
}

if (property.example) {
newProperty.example = property.example;
}

if (property.enum) {
newProperty.enum = property.enum;
}
Expand Down Expand Up @@ -666,6 +670,7 @@ export class SwaggerService {
swaggerBuildDefinitionModelProperty.description = args.description;
swaggerBuildDefinitionModelProperty.enum = args.enum;
swaggerBuildDefinitionModelProperty.itemType = args.itemType;
swaggerBuildDefinitionModelProperty.example = args.example;
if (args.model) {
swaggerBuildDefinitionModelProperty.model = args.model;
if (!_.isEqual("Array", propertyType)) {
Expand Down