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

Possibility to exclude specific object from handling #70

Merged
Merged
Show file tree
Hide file tree
Changes from 14 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
25 changes: 25 additions & 0 deletions .surfgen.generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@ useNewNullableDeterminationStrategy: true
prefixesToCutDownInServiceNames:
- "/api/v1"

# Will remove OpenAPI node by path /components/schemas/BadModel
# in file Tests/Common/NodeExcluding/models.yaml
#
# At run time. It doesn't touch real files
#
# In generated code all referenes to removed nodes will be generated as `TODO` string
LastSprint marked this conversation as resolved.
Show resolved Hide resolved
#
# You can remove by this leaf nodes like:
# - /components/schemas/*
# - /components/parameters/*
# - /components/header/*
# - /components/responses/*
# - /components/requestBodies/*
# - /paths/**/*
#
# To exclude specific operation you can write something like
# /paths/api/v1.1/auth~post
# Where:
# - `paths` - constant from OpenAPI specification
# - `/api/v1.1/auth` - method URI (just like in scpecification)
LastSprint marked this conversation as resolved.
Show resolved Hide resolved
# - `post` - operation (you can skip it to remove whole method). Symbol ~ is used to mark specific operation.
exludedNodes:
- "Tests/Common/NodeExcluding/models.yaml#/components/schemas/BadModel"
- "Tests/Common/NodeExcluding/api.yaml#/paths/api/v1.1/superAuth~delete"

templates:

# This option will generate Interface (Protocol) for service
Expand Down
25 changes: 24 additions & 1 deletion .surfgen.linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,27 @@ analytcsConfig:

# List of files (not directories) which must be excluded from linting
exclude:
- "./api/auth/api.yaml"
- "./api/auth/api.yaml"

# Will remove OpenAPI node by path /components/schemas/BadModel
# in file Tests/Common/NodeExcluding/models.yaml
#
# At run time. It doesn't touch real files
#
# You can remove by this leaf nodes like:
# - /components/schemas/*
# - /components/parameters/*
# - /components/header/*
# - /components/responses/*
# - /components/requestBodies/*
# - /paths/**/*
#
# To exclude specific operation you can write something like
# /paths/api/v1.1/auth~post
# Where:
# - `paths` - constant from OpenAPI specification
# - `/api/v1.1/auth` - method URI (just like in scpecification)
LastSprint marked this conversation as resolved.
Show resolved Hide resolved
# - `post` - operation (you can skip it to remove whole method). Symbol ~ is used to mark specific operation.
exludedNodes:
- "Tests/Common/NodeExcluding/models.yaml#/components/schemas/BadModel"
- "Tests/Common/NodeExcluding/api.yaml#/paths/api/v1.1/superAuth~delete"
Binary file modified Binary
Binary file not shown.
20 changes: 1 addition & 19 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
"version": "1.0.1"
}
},
{
"package": "Rainbow",
"repositoryURL": "https://github.com/onevcat/Rainbow",
"state": {
"branch": null,
"revision": "626c3d4b6b55354b4af3aa309f998fae9b31a3d9",
"version": "3.2.0"
}
},
{
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
Expand Down Expand Up @@ -87,7 +78,7 @@
"repositoryURL": "https://github.com/LastSprint/SwagGen",
"state": {
"branch": null,
"revision": "18ec072e675252e73f17174b56edd971d9b7a4b0",
"revision": "285ee89b027344520cbda903ea1c74bf0f9baac8",
"version": null
}
},
Expand All @@ -99,15 +90,6 @@
"revision": "2e949055d9797c1a6bddcda0e58dada16cc8e970",
"version": "6.0.3"
}
},
{
"package": "Yams",
LastSprint marked this conversation as resolved.
Show resolved Hide resolved
"repositoryURL": "https://github.com/jpsim/Yams",
"state": {
"branch": null,
"revision": "b08dba4bcea978bf1ad37703a384097d3efce5af",
"version": "1.0.2"
}
}
]
},
Expand Down
20 changes: 18 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ var testTargets: [Target] = [
),
.testTarget(
name: "PipelinesTests",
dependencies: ["Pipelines", "CodeGenerator", "Common", "ReferenceExtractor", "GASTBuilder", "UtilsForTesting", "PipelinesCLI"]
dependencies: ["Pipelines", "CodeGenerator", "Common", "ReferenceExtractor", "GASTBuilder", "UtilsForTesting", "PipelinesCLI", "ASTTree"]
),
.testTarget(
name: "CodeGeneratorTests",
dependencies: ["Pipelines", "CodeGenerator", "Common", "ReferenceExtractor", "GASTBuilder", "UtilsForTesting"]
),
.testTarget(
name: "ASTTreeTree",
dependencies: ["Pipelines", "ASTTree", "Common", "ReferenceExtractor", "UtilsForTesting"]
)
]

var dependencies: [PackageDescription.Package.Dependency] = [
// because SPM cant resolve it by their own ((((:
// .package(url: "https://github.com/kylef/PathKit.git", from: "0.9.0"),
.package(url: "https://github.com/LastSprint/SwagGen", .revision("18ec072e675252e73f17174b56edd971d9b7a4b0")),
.package(url: "https://github.com/LastSprint/SwagGen", .revision("285ee89b027344520cbda903ea1c74bf0f9baac8")),
.package(url: "https://github.com/stencilproject/Stencil", from: "0.14.1"),
.package(url: "https://github.com/jakeheis/SwiftCLI", from: "6.0.3"),
.package(url: "https://github.com/onevcat/Rainbow", from: "3.1.5"),
Expand All @@ -40,6 +44,10 @@ let package = Package(

// MARK: -- Shared

.library(
name: "ASTTree",
targets: ["ASTTree"]
),
.library(
name: "GASTTree",
targets: ["GASTTree"]
Expand Down Expand Up @@ -133,6 +141,14 @@ let package = Package(
name: "GASTTree",
dependencies: [
"Swagger",
"Common",
"ASTTree"
]
),
.target(
name: "ASTTree",
dependencies: [
"Swagger",
"Common"
]
),
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ where `pathToSpec` is a path to one file in OpenAPI spec **which describes servi
| `templates`| Contains array of structures called `Tenpmlate` |
| `prefixesToCutDownInServiceNames` | See [Prefix Cutting](#prefix-cutting)|
| `useNewNullableDeterminationStrategy` | See [Nullability](#nullability) |
| `exludedNodes` | See [NodesCutting](#node-cutting) |

## Editing templates

Expand Down Expand Up @@ -206,6 +207,36 @@ prefixesToCutDownInServiceNames:
- /api/test
```

### Node Cutting

SurfGen have an ability to cut specific OpenAPI node at run-time.

If you want to exclude some model or method from linting or generation you can utilize this functionality

```Yaml
exludedNodes:
- "Tests/Common/NodeExcluding/models.yaml#/components/schemas/BadModel"
- "Tests/Common/NodeExcluding/api.yaml#/paths/api/v1.1/superAuth~delete"
```
This comfiguration will remove model `/components/schemas/BadModel` which is located in file `./Tests/Common/NodeExcluding/models.yaml`

And will remove operation `delete` from path `/api/v1.1/superAuth` which is located in file `./Tests/Common/NodeExcluding/api.yaml`

You can remove by this way leaf nodes like:
- /components/schemas/*
- /components/parameters/*
- /components/header/*
- /components/responses/*
- /components/requestBodies/*
- /paths/*

To exclude specific operation you can write something like `/paths/api/v1.1/auth~post`

Where:
- `paths` - constant from OpenAPI specification
- `/api/v1.1/auth` - method URI (just like in scpecification)
LastSprint marked this conversation as resolved.
Show resolved Hide resolved
- `post` - operation (you can skip it to remove whole method). Symbol ~ is used to mark specific operation.

## Unsupported OpenAPI features

- We don't support key `not`
Expand Down
Loading