Skip to content

Commit

Permalink
Merge branch 'master' into THREESCALE-10245-expire-access-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jlledom authored Nov 26, 2024
2 parents e8af53e + 48f32d6 commit 058be50
Show file tree
Hide file tree
Showing 39 changed files with 1,819 additions and 2,040 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ gem 'diff-lcs', '~> 1.2'
gem 'hiredis-client'
gem 'httpclient', github: '3scale/httpclient', branch: 'ssl-env-cert'
gem 'json-schema', git: 'https://github.com/3scale/json-schema.git'
gem 'json_schemer'
gem 'local-fastimage_resize', '~> 3.4.0', require: 'fastimage/resize'
gem 'kt-paperclip', '~> 7.2'
gem 'matrix', '~> 0.4.2' # needed only until we upgrade capybara and prawn that list it as a dependency
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ GEM
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
hana (1.3.7)
has_scope (0.8.1)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand Down Expand Up @@ -427,6 +428,11 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.7.1)
json_schemer (2.3.0)
bigdecimal
hana (~> 1.3)
regexp_parser (~> 2.0)
simpleidn (~> 0.2)
jsonpath (1.1.2)
multi_json
jwt (1.5.6)
Expand Down Expand Up @@ -819,6 +825,7 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
simpleidn (0.2.3)
slim (4.0.1)
temple (>= 0.7.6, < 0.9)
tilt (>= 2.0.6, < 2.1)
Expand Down Expand Up @@ -1015,6 +1022,7 @@ DEPENDENCIES
jquery-rails (~> 4.4)
json (~> 2.7, >= 2.7.1)
json-schema!
json_schemer
jwt (~> 1.5.2)
kt-paperclip (~> 7.2)
kubeclient
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/finance/api/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def index
# GET /api/invoices/{id}.xml
def show
respond_with(invoice) do |format|
format.pdf { redirect_to invoice.pdf.url }
format.pdf { redirect_to invoice.pdf.expiring_url }
end
end

Expand Down
16 changes: 15 additions & 1 deletion app/javascript/src/ActiveDocs/ThreeScaleApiDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { autocompleteRequestInterceptor } from 'ActiveDocs/OAS3Autocomplete'
import type { AccountDataResponse, ApiDocsServices, BackendApiReportBody, BackendApiTransaction, BodyValue, BodyValueObject, FormData } from 'Types/SwaggerTypes'
import type { ExecuteData } from 'swagger-client/es/execute'
import type { SwaggerUIPlugin } from 'swagger-ui'
import type { Component } from 'react'
import type { SwaggerUIContext, ParameterIncludeEmptyProperties } from 'swagger-ui-utils'

const getApiSpecUrl = (baseUrl: string, specPath: string): string => {
return `${baseUrl.replace(/\/$/, '')}${specPath}`
Expand Down Expand Up @@ -118,6 +120,18 @@ const RequestBodyTransformerPlugin: SwaggerUIPlugin = () => {
}
}

const UncheckSendEmptyValuePlugin: SwaggerUIPlugin = () => {
return {
wrapComponents: {
// eslint-disable-next-line @typescript-eslint/naming-convention
ParameterIncludeEmpty: (originalComponent: Component, { React }: SwaggerUIContext ) => function ParameterIncludeEmptyWrapped (props: ParameterIncludeEmptyProperties) {
props.isIncludedOptions.defaultValue = false
return React.createElement(originalComponent, props)
}
}
}
}

export const renderSwaggerUI = async (container: HTMLElement, apiDocsPath: string, baseUrl: string, accountDataUrl: string): Promise<void> => {
const apiSpecs: ApiDocsServices = await fetchData<ApiDocsServices>(apiDocsPath)

Expand All @@ -134,7 +148,7 @@ export const renderSwaggerUI = async (container: HTMLElement, apiDocsPath: strin
requestInterceptor: (request) => autocompleteRequestInterceptor(request, accountData, ''),
tryItOutEnabled: true,
plugins: [
RequestBodyTransformerPlugin
RequestBodyTransformerPlugin, UncheckSendEmptyValuePlugin
]
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ApiJsonSpecInput: FunctionComponent<Props> = ({
fieldId="api_docs_service_body"
helperText={(
<>
Specification must comply with Swagger <a href="https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#52-api-declaration">1.2</a>, <a href="https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md">2.0</a> or <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md">3.0</a>
Specification must comply with Swagger <a href="https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md">2.0</a>, or OpenAPI specification <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md">3.0</a> or <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md">3.1</a>
</>
)}
helperTextInvalid={errors.join(', ')}
Expand Down
19 changes: 19 additions & 0 deletions app/javascript/src/Types/swagger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,22 @@ declare module 'swagger-client/es/execute' {
function execute (req: ExecuteData): unknown
export { execute }
}

declare module 'swagger-ui-utils' {
import type { Component } from 'react'

export interface ReactType {
createElement: (Original: Component, props: ParameterIncludeEmptyProperties) => Component;
}

export interface SwaggerUIContext {
// eslint-disable-next-line @typescript-eslint/naming-convention
React: ReactType;
}

export interface ParameterIncludeEmptyProperties {
isIncludedOptions: {
defaultValue: boolean;
};
}
}
Loading

0 comments on commit 058be50

Please sign in to comment.