Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f9e7ff5
feat: add ExportRestOperationsGroupStrategy
CountRedClaw Apr 21, 2025
357c3ff
fix: documents renaming test
CountRedClaw Apr 22, 2025
40f8436
refactor: refine types
CountRedClaw Apr 23, 2025
8c91d1f
refactor: refine types
CountRedClaw Apr 23, 2025
59c555a
feat: add ExportRestDocumentStrategy and ExportVersionStrategy
CountRedClaw May 23, 2025
b37f04c
test: fix tests
CountRedClaw May 23, 2025
b25ce4d
Merge remote-tracking branch 'refs/remotes/origin/develop' into featu…
CountRedClaw May 23, 2025
c6df508
chore: update api-unifier & api-diff versions
CountRedClaw May 23, 2025
019b28f
chore: update api-unifier & api-diff versions
CountRedClaw May 23, 2025
85ed0aa
fix: duplicated parse call
CountRedClaw May 26, 2025
1ec70e7
feat: support doc and version export to html
CountRedClaw May 30, 2025
e727c4a
chore: cleanup
CountRedClaw May 30, 2025
ebba502
feat: add readme feature
CountRedClaw Jun 3, 2025
ac9bceb
fix: back link
CountRedClaw Jun 3, 2025
d016e33
fix: make exportFileName optional
CountRedClaw Jun 3, 2025
f72c004
fix: tests
CountRedClaw Jun 3, 2025
8073a1b
fix: issues found during dev-test
CountRedClaw Jun 3, 2025
0877384
fix: templates path
CountRedClaw Jun 4, 2025
b992819
fix: add test resources
CountRedClaw Jun 4, 2025
93415ca
feat: add operation group export support
CountRedClaw Jun 4, 2025
7bd1fbd
fix: tests
CountRedClaw Jun 4, 2025
6e3eb2c
fix: unable to read the file by slug
CountRedClaw Jun 4, 2025
f46c5c0
fix: "export" test resource folder exclusion
CountRedClaw Jun 5, 2025
d55daae
fix: don't add index.html in case of one spec and no readme
CountRedClaw Jun 5, 2025
b72c9e1
fix: don't add index.html in case of one spec and no readme
CountRedClaw Jun 5, 2025
874f81f
feat: use templateResolver to allow template overriding
CountRedClaw Jun 9, 2025
6f53490
fix: comment saving exported archives to fs to fix tests on CI
CountRedClaw Jun 9, 2025
dae1451
fix: rename operations group export strategy
CountRedClaw Jun 9, 2025
279e5d1
fix: use packageName instead of packageId in html
CountRedClaw Jun 9, 2025
0e94d38
fix: package types export
CountRedClaw Jun 9, 2025
6d5aeb3
fix: export files should use version without revision
CountRedClaw Jun 10, 2025
c3a6463
fix: tests
CountRedClaw Jun 10, 2025
144d332
chore: set dev versions for dependencies
b41ex Jun 10, 2025
c3718ee
fix: align media type handling logic with the actual BE behaviour
CountRedClaw Jun 11, 2025
9f696fe
fix: replace svg logo with png
CountRedClaw Jun 12, 2025
5a7c088
fix: graphql export
CountRedClaw Jun 12, 2025
5ffeec9
Merge remote-tracking branch 'refs/remotes/origin/develop' into featu…
CountRedClaw Jun 12, 2025
7cb0e31
chore: update lock file
CountRedClaw Jun 12, 2025
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ temp
coverage
.idea
.DS_store
export
dist/
*.iml
test/versions/
159 changes: 137 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"update-lock-file": "update-lock-file @netcracker"
},
"dependencies": {
"@netcracker/qubership-apihub-api-diff": "2.0.1",
"@netcracker/qubership-apihub-api-unifier": "2.0.0",
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
"@netcracker/qubership-apihub-api-diff": "dev",
"@netcracker/qubership-apihub-api-unifier": "dev",
"@netcracker/qubership-apihub-graphapi": "1.0.8",
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
"adm-zip": "0.5.10",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
Expand All @@ -53,6 +53,7 @@
"@types/adm-zip": "0.5.7",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.5",
"@types/mime-types": "^3.0.0",
"@types/node": "^18.0.0",
"@types/object-hash": "^3.0.2",
"@types/slug": "^5.0.3",
Expand All @@ -64,7 +65,9 @@
"eslint-plugin-sort-exports": "^0.8.0",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"mime-types": "^3.0.1",
"openapi-types": "^12.1.0",
"rollup-plugin-copy": "^3.5.0",
"ts-jest": "29.1.2",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
Expand Down
8 changes: 7 additions & 1 deletion src/apitypes/graphql/graphql.document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@ export const buildGraphQLDocument: DocumentBuilder<GraphApiSchema> = async (pars
}

export const dumpGraphQLDocument: DocumentDumper<GraphApiSchema> = (document) => {
return new Blob([printGraphApi(document.data)], { type: 'text/plain' })
if (document.data) {
return new Blob([printGraphApi(document.data)], { type: 'text/plain' })
}
if (document.source) {
return document.source
}
throw new Error(`Document ${document.fileId} has neither data nor source`)
}
14 changes: 13 additions & 1 deletion src/apitypes/rest/rest.consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

import { FILE_FORMAT_JSON, FILE_FORMAT_YAML, FILE_FORMAT_YML } from '../../consts'
import { KeyOfConstType, ResolvedVersionDocument, ZippableDocument } from '../../types'
import { TEXT_DOCUMENT_TYPE, TextDocumentType } from '../text'

export const REST_API_TYPE = 'rest' as const

Expand All @@ -33,12 +35,22 @@ export const REST_DOCUMENT_TYPE = {
SWAGGER: 'openapi-2-0',
} as const

export type RestDocumentType = KeyOfConstType<typeof REST_DOCUMENT_TYPE>

export const REST_FILE_FORMAT = {
YAML: FILE_FORMAT_YAML,
YML: FILE_FORMAT_YML,
JSON: FILE_FORMAT_JSON,
}
} as const

export const REST_KIND_KEY = 'x-api-kind'

export const DEPRECATED_META_KEY = 'x-deprecated-meta'

export function isRestDocument(document: ZippableDocument | ResolvedVersionDocument): boolean {
return Object.values(REST_DOCUMENT_TYPE).includes(document.type as RestDocumentType)
}

export function isTextDocument(document: ResolvedVersionDocument): boolean {
return Object.values(TEXT_DOCUMENT_TYPE).includes(document.type as TextDocumentType)
}
2 changes: 1 addition & 1 deletion src/apitypes/rest/rest.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const parseRestFile = async (fileId: string, source: Blob): Promise<TextF
kind: FILE_KIND.TEXT,
}
}
} else if ([REST_FILE_FORMAT.YAML, REST_FILE_FORMAT.YML].includes(extension) || !extension) {
} else if (([REST_FILE_FORMAT.YAML, REST_FILE_FORMAT.YML] as string[]).includes(extension) || !extension) {
if (/\s*?'?"?openapi'?"?\s*?:\s*?\|?\s*'?"?3\.[01]\..+?'?"?/g.test(sourceString)) {
const data = YAML.load(sourceString) as OpenAPIV3.Document

Expand Down
3 changes: 3 additions & 0 deletions src/apitypes/text/text.consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { KeyOfConstType } from '../../types'

export const TEXT_API_TYPE = 'text' as const

export const TEXT_DOCUMENT_TYPE = {
MARKDOWN: 'markdown',
} as const

export type TextDocumentType = KeyOfConstType<typeof TEXT_DOCUMENT_TYPE>

export const TEXT_FILE_FORMAT = {
MD: 'md',
} as const
4 changes: 2 additions & 2 deletions src/apitypes/unknown/unknown.document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { BuildConfigFile, DocumentBuilder, DocumentDumper, File, VersionDocument } from '../../types'
import { BuildConfigFile, DocumentBuilder, DocumentDumper, SourceFile, VersionDocument } from '../../types'
import { createBundlingErrorHandler, getBundledFileDataWithDependencies, getDocumentTitle } from '../../utils'
import { FILE_FORMAT } from '../../consts'

Expand Down Expand Up @@ -57,7 +57,7 @@ export const buildUnknownDocument: DocumentBuilder<string> = async (parsedFile,
}
}

export const buildBinaryDocument: (parsedFile: File, file: BuildConfigFile) => Promise<VersionDocument> = async (parsedFile, file) => {
export const buildBinaryDocument: (parsedFile: SourceFile, file: BuildConfigFile) => Promise<VersionDocument> = async (parsedFile, file) => {
const { fileId, slug = '', publish, ...metadata } = file
const { type, format, source } = parsedFile

Expand Down
Loading