Skip to content

Commit

Permalink
refactor: improve api schema (#2109)
Browse files Browse the repository at this point in the history
* format yaml

* add operationId to all endpoints

* marked rooms api as deprecated

* add tags to each endpoints

* moved unused components to db-schema

* add examples

* override name for sdk generation

* override operation name for sdk generatino

* run prettier & fix typo

* Update packages/api/src/schema/api-schema.yaml

Co-authored-by: Victor Elias <[email protected]>

* Update packages/api/src/schema/api-schema.yaml

Co-authored-by: Victor Elias <[email protected]>

* Update packages/api/src/schema/api-schema.yaml

Co-authored-by: Victor Elias <[email protected]>

* Update api-schema.yaml

* fix: build error

* revert: add new-asset-from-url-payload to api-schema.yaml

* Update api-schema.yaml

* fix build issue

* hardcoded inputcreator filter

* fix: create stream and loosening schema (#2134)

* Update compile-schemas.js

* fix: tsconfig

* fix: revert additionalproperties

* fix: remove InputCreatorId unknown

* fix: api schema

* fix: api schema

* fix: revert changes to additional properties

* fix: fixes from review

* fix: lint

---------

Co-authored-by: Victor Elias <[email protected]>
Co-authored-by: Chase Adams <[email protected]>
  • Loading branch information
3 people authored Apr 23, 2024
1 parent 6554996 commit 47dbc3c
Show file tree
Hide file tree
Showing 5 changed files with 664 additions and 269 deletions.
14 changes: 12 additions & 2 deletions packages/api/src/compile-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const data = _.merge({}, apiData, dbData);
const ajv = new Ajv({ sourceCode: true });

const index = [];
const types = [];
let types = [];

for (const [name, schema] of Object.entries(data.components.schemas)) {
schema.title = name;
Expand All @@ -72,7 +72,17 @@ const data = _.merge({}, apiData, dbData);
const indexPath = path.resolve(validatorDir, "index.js");
write(indexPath, indexStr);

const typeStr = types.join("\n");
const typeDefinition = `export type InputCreatorId =
| {
type: "unverified";
value: string;
}
| string;`;

let typeStr = types.join("\n\n");
const cleanedTypeStr = typeStr.split(typeDefinition).join("");
typeStr = `${cleanedTypeStr.trim()}\n\n${typeDefinition}`;

const typePath = path.resolve(schemaDir, "types.d.ts");
write(typePath, typeStr);
})().catch((err) => {
Expand Down
Loading

0 comments on commit 47dbc3c

Please sign in to comment.