Skip to content

Commit

Permalink
Merge pull request #228 from opticdev/fix/content-type-create
Browse files Browse the repository at this point in the history
Fixed content type for create / update types
  • Loading branch information
cmars authored Mar 29, 2022
2 parents 268ce73 + aa5f4aa commit bc28a01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/workflows/templates/operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function buildCreateOperation(
parameters: commonParameters,
requestBody: {
content: {
"application/json": {
"application/vnd.api+json": {
schema: createRequestSchema,
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/workflows/templates/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function buildUpdateOperation(
],
requestBody: {
content: {
"application/json": {
"application/vnd.api+json": {
schema: updateRequestSchema,
},
},
Expand Down
42 changes: 25 additions & 17 deletions src/workflows/templates/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,20 @@ export function buildCreateRequestSchema(
): OpenAPIV3.SchemaObject {
return {
type: "object",
required: ["id", "type"],
required: ["data"],
properties: {
id: {
type: "string",
format: "uuid",
},
type: {},
attributes: {
$ref: `#/components/schemas/${titleResourceName}CreateAttributes`,
data: {
type: "object",
required: ["type"],
properties: {
type: refs.schemas.types,
attributes: {
$ref: `#/components/schemas/${titleResourceName}CreateAttributes`,
},
},
additionalProperties: false,
},
},
additionalProperties: false,
};
}

Expand All @@ -84,17 +86,23 @@ export function buildUpdateRequestSchema(
): OpenAPIV3.SchemaObject {
return {
type: "object",
required: ["data"],
properties: {
id: {
type: "string",
format: "uuid",
},
type: {},
attributes: {
$ref: `#/components/schemas/${titleResourceName}UpdateAttributes`,
data: {
type: "object",
properties: {
id: {
type: "string",
format: "uuid",
},
type: refs.schemas.types,
attributes: {
$ref: `#/components/schemas/${titleResourceName}UpdateAttributes`,
},
},
additionalProperties: false,
},
},
additionalProperties: false,
};
}

Expand Down

0 comments on commit bc28a01

Please sign in to comment.