Skip to content

feat(spec): commit bundled specs #134

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

Merged
merged 6 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 9 additions & 9 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,63 +44,63 @@ runs:
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-search/dist
key: ${{ runner.os }}-1-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-search/**') }}-${{ hashFiles('specs/dist/search.yml') }}
key: ${{ runner.os }}-1-js-client-search-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-search/**') }}-${{ hashFiles('specs/bundled/search.yml') }}

- name: Restore built JavaScript recommend client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/recommend/dist
key: ${{ runner.os }}-1-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/packages/recommend/**') }}-${{ hashFiles('specs/dist/recommend.yml') }}
key: ${{ runner.os }}-1-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/packages/recommend/**') }}-${{ hashFiles('specs/bundled/recommend.yml') }}

- name: Restore built JavaScript query-suggestions client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-query-suggestions/dist
key: ${{ runner.os }}-1-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-query-suggestions/**') }}-${{ hashFiles('specs/dist/query-suggestions.yml') }}
key: ${{ runner.os }}-1-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-query-suggestions/**') }}-${{ hashFiles('specs/bundled/query-suggestions.yml') }}

- name: Restore built JavaScript personalization client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-personalization/dist
key: ${{ runner.os }}-1-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-personalization/**') }}-${{ hashFiles('specs/dist/personalization.yml') }}
key: ${{ runner.os }}-1-js-client-personalization-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-personalization/**') }}-${{ hashFiles('specs/bundled/personalization.yml') }}

- name: Restore built JavaScript analytics client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-analytics/dist
key: ${{ runner.os }}-1-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-analytics/**') }}-${{ hashFiles('specs/dist/analytics.yml') }}
key: ${{ runner.os }}-1-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-analytics/**') }}-${{ hashFiles('specs/bundled/analytics.yml') }}

- name: Restore built JavaScript abtesting client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-abtesting/dist
key: ${{ runner.os }}-1-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-abtesting/**') }}-${{ hashFiles('specs/dist/abtesting.yml') }}
key: ${{ runner.os }}-1-js-client-abtesting-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-abtesting/**') }}-${{ hashFiles('specs/bundled/abtesting.yml') }}

- name: Restore built JavaScript insights client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-insights/dist
key: ${{ runner.os }}-1-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-insights/**') }}-${{ hashFiles('specs/dist/insights.yml') }}
key: ${{ runner.os }}-1-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-insights/**') }}-${{ hashFiles('specs/bundled/insights.yml') }}

- name: Restore built JavaScript sources client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/packages/client-sources/dist
key: ${{ runner.os }}-1-js-client-sources-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-sources/**') }}-${{ hashFiles('specs/dist/sources.yml') }}
key: ${{ runner.os }}-1-js-client-sources-${{ hashFiles('clients/algoliasearch-client-javascript/packages/client-sources/**') }}-${{ hashFiles('specs/bundled/sources.yml') }}

- name: Restore built Java client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-java-2/target
key: ${{ runner.os }}-1-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}-${{ hashFiles('specs/dist/search.yml') }}
key: ${{ runner.os }}-1-java-client-${{ hashFiles('clients/algoliasearch-client-java-2/**') }}-${{ hashFiles('specs/bundled/search.yml') }}

# setup yarn
- name: Get yarn cache directory path
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: yarn build:specs ${{ matrix.client }}

- name: Check diff with pushed spec
run: exit $(git status --porcelain specs/dist/${{ matrix.client }}.yml | wc -l)
run: exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l)

client_javascript:
timeout-minutes: 10
Expand All @@ -84,7 +84,7 @@ jobs:
uses: actions/cache@v2
with:
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/dist'
key: ${{ runner.os }}-1-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/dist/{0}.yml', matrix.client.name)) }}
key: ${{ runner.os }}-1-js-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }}

- name: Generate ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
uses: actions/cache@v2
with:
path: '/home/runner/work/api-clients-automation/api-clients-automation/${{ matrix.client.folder }}/target'
key: ${{ runner.os }}-1-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/dist/{0}.yml', matrix.client.name)) }}
key: ${{ runner.os }}-1-java-client-${{ matrix.client.name }}-${{ hashFiles(format('{0}/**', matrix.client.folder)) }}-${{ hashFiles(format('specs/bundled/{0}.yml', matrix.client.name)) }}

- name: Generate ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ target
build

dist
!specs/dist
specs/dist/*.cache

.openapi-generator
6 changes: 3 additions & 3 deletions doc/CTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ The test generation script requires a JSON file name from the `operationId` (e.g
"searchParam": {
"$objectName": "the name of the object for strongly type language, should be on every 'object' type (can be 'Object' if free-form)",
"query": "the string to search",
"acl": {
"acl": {
"$enumType": "the name of the enum object if marked as enum in the spec",
"value": "the string value of the enum",
"value": "the string value of the enum"
}
}
},
Expand Down Expand Up @@ -117,6 +117,6 @@ When writing your template, here is a list of variables accessible from `mustach
To get the list of `operationId` not yet in the CTS but in the spec, run this command:

```bash
rm -rf ./specs/dist
rm -rf ./specs/bundled
comm -3 <(grep -r operationId ./specs | awk -F: '{gsub(/ /,""); print $NF}' | sort) <(find ./tests/CTS/clients -type f -name '*.json' | awk -F/ '{gsub(/.json/,"");print $NF}' | sort)
```
32 changes: 16 additions & 16 deletions openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-search",
"glob": "specs/dist/search.yml",
"glob": "specs/bundled/search.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -30,7 +30,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/recommend",
"glob": "specs/dist/recommend.yml",
"glob": "specs/bundled/recommend.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -51,7 +51,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-personalization",
"glob": "specs/dist/personalization.yml",
"glob": "specs/bundled/personalization.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -75,7 +75,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-analytics",
"glob": "specs/dist/analytics.yml",
"glob": "specs/bundled/analytics.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -100,7 +100,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-insights",
"glob": "specs/dist/insights.yml",
"glob": "specs/bundled/insights.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -125,7 +125,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-abtesting",
"glob": "specs/dist/abtesting.yml",
"glob": "specs/bundled/abtesting.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -150,7 +150,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-query-suggestions",
"glob": "specs/dist/query-suggestions.yml",
"glob": "specs/bundled/query-suggestions.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand All @@ -174,7 +174,7 @@
"config": "#{cwd}/openapitools.json",
"apiPackage": "src",
"output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-sources",
"glob": "specs/dist/sources.yml",
"glob": "specs/bundled/sources.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-javascript",
Expand Down Expand Up @@ -203,7 +203,7 @@
"invokerPackage": "com.algolia",
"modelPackage": "com.algolia.model",
"library": "okhttp-gson",
"glob": "specs/dist/search.yml",
"glob": "specs/bundled/search.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-java-2",
Expand All @@ -219,7 +219,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/search.yml",
"glob": "specs/bundled/search.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand All @@ -237,7 +237,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/recommend.yml",
"glob": "specs/bundled/recommend.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand All @@ -255,7 +255,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/personalization.yml",
"glob": "specs/bundled/personalization.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand All @@ -277,7 +277,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/analytics.yml",
"glob": "specs/bundled/analytics.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand All @@ -300,7 +300,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/insights.yml",
"glob": "specs/bundled/insights.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand All @@ -323,7 +323,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/abtesting.yml",
"glob": "specs/bundled/abtesting.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand All @@ -346,7 +346,7 @@
"templateDir": "#{cwd}/templates/php/",
"config": "#{cwd}/openapitools.json",
"output": "#{cwd}/clients/algoliasearch-client-php",
"glob": "specs/dist/query-suggestions.yml",
"glob": "specs/bundled/query-suggestions.yml",
"gitHost": "algolia",
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
Expand Down
6 changes: 3 additions & 3 deletions scripts/builds/specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ check_format_spec() {

build_spec() {
local client=$1
yarn openapi bundle specs/${client}/spec.yml -o specs/dist/${client}.${OUTPUT} --ext ${OUTPUT}
yarn openapi bundle specs/${client}/spec.yml -o specs/bundled/${client}.${OUTPUT} --ext ${OUTPUT}
echo ""
}

validate_output_spec() {
local client=$1
yarn openapi lint specs/dist/${client}.${OUTPUT}
yarn openapi lint specs/bundled/${client}.${OUTPUT}
echo ""
}

CLIENTS=$(find specs/*/spec.yml | awk -F / '{ print $(NF-1) }')
CLIENTS=($(find specs/*/spec.yml | awk -F / '{ print $(NF-1) }'))

if [[ $CLIENT == "all" ]]; then
CLIENTS=("${CLIENTS[@]}")
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ compute_hash() {
# build spec before generating client
build_spec() {
# check if file and cache exist
mkdir -p specs/dist
cacheFile="specs/dist/$CLIENT.cache"
if [[ -f specs/dist/$CLIENT.yml ]]; then
if [[ -f specs/bundled/$CLIENT.yml ]]; then
cache=$(compute_hash)
# compare with stored cache
if [[ -f $cacheFile && $(cat $cacheFile) == $cache ]]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/pre-gen/setHostsOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function setHostsOptions(): Promise<void> {
throw new Error(`Generator not found: ${generator}`);
}

const specPath = path.join(__dirname, `../../specs/dist/${client}.yml`);
const specPath = path.join(__dirname, `../../specs/bundled/${client}.yml`);

if (!(await stat(specPath))) {
throw new Error(`File not found ${specPath}`);
Expand Down
3 changes: 2 additions & 1 deletion specs/dist/README.md → specs/bundled/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

**Please do not edit the files in this folder, they are generated and changes will be overwritten on next use**

Output folder of the specs located in `/specs/CLIENT_NAME/spec.yml`.
Output folder of the specs located in `/specs/<CLIENT_NAME>/spec.yml`.

This folder hosts the bundled specs used to:

- Generate clients.
- Generate documentation.
- Share single readable spec file for a specific client.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ components:
List of facet attributes used to generate Query Suggestions. The
resulting suggestions are every combination of the facets in the nested
list (e.g., (facetA and facetB) and facetC).
example:
- - facetA
- facetB
- - facetC
example: '[[facetA, facetB], [facetC]]'
SourceIndexExternal:
type: object
additionalProperties: false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion specs/query-suggestions/common/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ generate:
type: string
default: []
description: List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC).
example: [[facetA, facetB], [facetC]]
example: '[[facetA, facetB], [facetC]]'

external:
type: array
Expand Down