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

Improve exclusion of operation IDs #215

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ api/openapi.yaml

README.md

# We exclude some operations from the generated library by ID. openapi-generator does not have a way for us to do that
# directly, so we must do it by filename here, and also separately by Handlebars expressions in the
# partial_filter_operation template.

model_*2_request.go
model_*2_response.go
model_*3_request.go
model_*3_response.go
model_*4_request.go
model_*4_response.go
model_enterprise_stub*_request.go
model_enterprise_stub*_response.go

docs/*2Request.md
docs/*2Response.md
docs/*3Request.md
docs/*3Response.md
docs/*4Request.md
docs/*4Response.md
docs/EnterpriseStub*Request.md
docs/EnterpriseStub*Response.md

configuration.go
response.go
Expand Down
9 changes: 2 additions & 7 deletions generate/templates/api.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ type {{cut classname "Api"}} struct {
client *Client
}
{{#each operation}}
{{#endsWith nickname "2"}}{{else}}
{{#endsWith nickname "3"}}{{else}}
{{#endsWith nickname "4"}}{{else}}

{{#>partial_filter_operation}}
{{#if isDeprecated}}
// Deprecated{{/if}}
// {{operationId}} {{#if summary}}{{{summary}}}{{/if}}{{#if notes}}
Expand Down Expand Up @@ -70,8 +67,6 @@ func ({{lower (substring classname 0 1)}} *{{cut classname "Api"}}) {{nickname}}
)
{{/unless}}
}
{{/endsWith}}
{{/endsWith}}
{{/endsWith}}
{{/partial_filter_operation}}
{{/each}}
{{/with}}
22 changes: 6 additions & 16 deletions generate/templates/api_doc.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ Method | HTTP request | Description
------------- | ------------- | -------------
{{#with operations ~}}
{{#each operation ~}}
{{#endsWith operationId "2"}}{{else ~}}
{{#endsWith operationId "3"}}{{else ~}}
{{#endsWith operationId "4"}}{{else ~}}
[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#if summary}}{{summary}}{{/if}}
{{/endsWith ~}}
{{/endsWith ~}}
{{/endsWith ~}}
{{/each ~}}
{{#>partial_filter_operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#if summary}}{{summary}}{{/if}}
{{/partial_filter_operation}}
{{~/each ~}}
{{/with ~}}

{{#with operations}}
{{#each operation ~}}
{{#endsWith operationId "2"}}{{else ~}}
{{#endsWith operationId "3"}}{{else ~}}
{{#endsWith operationId "4"}}{{else ~}}
## {{{operationId}}}
{{#>partial_filter_operation}}## {{{operationId}}}

{{#if summary}}{{{summary}}}{{/if}}{{#if notes}}

Expand Down Expand Up @@ -87,8 +79,6 @@ Name | Type | Description | Notes
[[Back to top]](#)
[[Back to README]](../README.md)

{{/endsWith ~}}
{{/endsWith ~}}
{{/endsWith ~}}
{{/each ~}}
{{/partial_filter_operation}}
{{~/each ~}}
{{/with ~}}
8 changes: 8 additions & 0 deletions generate/templates/partial_filter_operation.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{#not (or
(endsWith operationId "2")
(endsWith operationId "3")
(endsWith operationId "4")
(startsWith operationId "EnterpriseStub")
) ~}}
{{> @partial-block }}
{{~/not ~}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice refactor 👍