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

Adds public function for setting info object directly #3626

Merged
merged 27 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
af56e27
Add support for extending a namespace
irvinesunday Jun 20, 2024
1bcfb65
Add extension on namespace test
irvinesunday Jun 20, 2024
fa4fc96
Update name used in test
irvinesunday Jun 20, 2024
502c55c
Fix file with prettier
irvinesunday Jun 20, 2024
8630b2a
Merge branch 'main' into irvine/set-info-extension
irvinesunday Jun 20, 2024
74bc354
Add new method to fetch namespace extensions
irvinesunday Jun 27, 2024
58f871d
Merge branch 'irvine/set-info-extension' of https://github.com/irvine…
irvinesunday Jun 27, 2024
5a91849
Merge branch 'main' into irvine/set-info-extension
irvinesunday Jun 27, 2024
2ced469
Use prettier on file
irvinesunday Jun 27, 2024
1bdbfc1
Merge branch 'irvine/set-info-extension' of https://github.com/irvine…
irvinesunday Jun 27, 2024
c34bccf
Add documentation for new functions
irvinesunday Jun 27, 2024
8bfc8fb
Add changeset
irvinesunday Jul 2, 2024
8a80082
Remove setNamespaceExtension
irvinesunday Jul 3, 2024
a9daf14
Update test message
irvinesunday Jul 3, 2024
5dc9076
Merge branch 'main' into irvine/set-info-extension
irvinesunday Jul 3, 2024
85d49e3
PR review suggestion
irvinesunday Jul 4, 2024
5b341bd
Remove test
irvinesunday Jul 4, 2024
7d71da8
Remove unnecessary functions
irvinesunday Jul 4, 2024
4dd8198
Use prettier
irvinesunday Jul 4, 2024
e1eaadb
Update changeset
irvinesunday Jul 4, 2024
230b6a7
Remove unnecessary code; whitespace
irvinesunday Jul 4, 2024
09af6a9
Merge branch 'main' into irvine/set-info-extension
irvinesunday Jul 4, 2024
b10145f
Merge branch 'main' into irvine/set-info-extension
irvinesunday Jul 5, 2024
0d20f1b
Merge branch 'main' into irvine/set-info-extension
irvinesunday Jul 8, 2024
edce4c3
Update packages/openapi/src/decorators.ts
timotheeguerin Jul 8, 2024
f70941b
Format
timotheeguerin Jul 8, 2024
89c0931
Fix build
timotheeguerin Jul 9, 2024
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
7 changes: 7 additions & 0 deletions .chronus/changes/set-info-object-2024-6-3-0-48-13.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/openapi"
---

Adds public function for setting info object
11 changes: 9 additions & 2 deletions packages/openapi/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export const $extension: ExtensionDecorator = (
setExtension(context.program, entity, extensionName as ExtensionKey, data);
};

export function setInfo(
program: Program,
entity: Namespace,
data: AdditionalInfo & Record<ExtensionKey, unknown>
) {
program.stateMap(infoKey).set(entity, data);
}

export function setExtension(
program: Program,
entity: Type,
Expand All @@ -78,7 +86,6 @@ export function setExtension(
const openApiExtensions = program.stateMap(openApiExtensionKey);
const typeExtensions = openApiExtensions.get(entity) ?? new Map<string, any>();
typeExtensions.set(extensionName, data);

openApiExtensions.set(entity, typeExtensions);
}

Expand Down Expand Up @@ -157,7 +164,7 @@ export const $info: InfoDecorator = (
if (data === undefined) {
return;
}
context.program.stateMap(infoKey).set(entity, data);
setInfo(context.program, entity, data);
};

export function getInfo(program: Program, entity: Namespace): AdditionalInfo | undefined {
Expand Down
Loading