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

fix: sdk generation error caused by incorrect swagger decorator #1455

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 3 additions & 6 deletions src/published-data/published-data.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from "./dto/update-published-data.dto";
import {
ApiBearerAuth,
ApiBody,
ApiOperation,
ApiParam,
ApiQuery,
Expand Down Expand Up @@ -76,10 +77,7 @@ export class PublishedDataController {
async create(
@Body() createPublishedDataDto: CreatePublishedDataDto,
): Promise<PublishedData> {
return this.publishedDataService.create({
...createPublishedDataDto,
status: "pending_registration",
});
return this.publishedDataService.create(createPublishedDataDto);
}

// GET /publisheddata
Expand Down Expand Up @@ -445,8 +443,7 @@ export class PublishedDataController {
description: "The DOI of the published data.",
type: String,
})
@ApiParam({
name: "data",
@ApiBody({
description:
"The edited data that will be updated in the database and with OAI Provider if defined.",
type: UpdatePublishedDataDto,
Expand Down
2 changes: 1 addition & 1 deletion src/published-data/schemas/published-data.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class PublishedData {
description:
"Indication of position in publication workflow e.g. doiRegistered",
})
@Prop({ type: String, required: false })
@Prop({ type: String, required: false, default: "pending_registration" })
status: string;

@ApiProperty({
Expand Down
18 changes: 17 additions & 1 deletion test/PublishedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let accessTokenAdminIngestor = null,
doi = null;

const publishedData = { ...TestData.PublishedData };
const defaultStatus = "pending_registration";

const origDataBlock = { ...TestData.OrigDataBlockCorrect1 };

Expand All @@ -38,7 +39,7 @@ describe("1600: PublishedData: Test of access to published data", () => {
db.collection("Dataset").deleteMany({});
db.collection("PublishedData").deleteMany({});
});
beforeEach(async() => {
beforeEach(async () => {
accessTokenAdminIngestor = await utils.getToken(appUrl, {
username: "adminIngestor",
password: TestData.Accounts["adminIngestor"]["password"],
Expand All @@ -65,10 +66,25 @@ describe("1600: PublishedData: Test of access to published data", () => {
.expect("Content-Type", /json/)
.then((res) => {
res.body.should.have.property("publisher").and.be.string;
res.body.should.have.property("status").and.equal(defaultStatus);
doi = encodeURIComponent(res.body["doi"]);
});
});

it("0015: adds a published data without specifying a status should assign the default status", async () => {
delete publishedData.status;
return request(appUrl)
.post("/api/v3/PublishedData")
.send(publishedData)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenAdminIngestor}` })
.expect(TestData.EntryCreatedStatusCode)
.expect("Content-Type", /json/)
.then((res) => {
res.body.should.have.property("status").and.equal(defaultStatus);
});
});

it("0020: should fetch this new published data without authorization", async () => {
return request(appUrl)
.get("/api/v3/PublishedData/" + doi)
Expand Down
Loading