Skip to content

Instantly share code, notes, and snippets.

@Dema
Created March 18, 2022 13:06
Show Gist options
  • Save Dema/01985a4a8f78040adcdf02b7d5cb8d76 to your computer and use it in GitHub Desktop.
Save Dema/01985a4a8f78040adcdf02b7d5cb8d76 to your computer and use it in GitHub Desktop.
oneOf issue
{
"openapi": "3.0.1",
"info": {
"title": "Challenge-service API",
"version": "1.0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"security": [
{
"BearerAuth": []
}
],
"tags": [
{
"name": "Challenge Api"
}
],
"paths": {
"/api/v1/challenges/{id}": {
"get": {
"tags": ["Challenge Api"],
"summary": "Get Challenge by Id",
"operationId": "findChallengeById",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Challenge Id",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ChallengeResponseDto"
}
}
}
}
}
},
"put": {
"tags": ["Challenge Api"],
"summary": "Update Challenge",
"operationId": "updateChallenge",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Challenge Id",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChallengeRequestDto"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ChallengeResponseDto"
}
}
}
}
}
},
"delete": {
"tags": ["Challenge Api"],
"summary": "Delete Challenge",
"operationId": "deleteChallenge",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Challenge Id",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v1/challenges": {
"get": {
"tags": ["Challenge Api"],
"summary": "Get Page of Challenge by Page number and Page size",
"operationId": "getChallengesPage",
"parameters": [
{
"name": "page",
"in": "query",
"description": "Zero-based page index (0..N)",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"default": 0
}
},
{
"name": "size",
"in": "query",
"description": "The size of the page to be returned",
"required": false,
"schema": {
"minimum": 1,
"type": "integer",
"default": 20
}
},
{
"name": "sort",
"in": "query",
"description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
"required": false,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/PageChallengeResponseDto"
}
}
}
}
}
},
"post": {
"tags": ["Challenge Api"],
"summary": "Create Challenge",
"operationId": "createChallenges",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChallengeRequestDto"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Created",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ChallengeResponseDto"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"AbstractRequestStepDto": {
"required": ["description", "stepType", "title"],
"type": "object",
"properties": {
"stepNumber": {
"minimum": 1,
"type": "integer",
"format": "int32"
},
"title": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"description": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"stepType": {
"type": "string",
"enum": [
"ACTIVITY",
"ACTION",
"DOWNLOAD_CONFIRMATION",
"LINK_CONFIRMATION"
]
}
},
"description": "Parent for all steps",
"discriminator": {
"propertyName": "stepType",
"mapping": {
"LINK_CONFIRMATION": "#/components/schemas/LinkConfirmationRequestDto",
"DOWNLOAD_CONFIRMATION": "#/components/schemas/DownloadConfirmationRequestDto",
"ACTIVITY": "#/components/schemas/ActivityRequestStepDto",
"ACTION": "#/components/schemas/ActionRequestStepDto"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/LinkConfirmationRequestDto"
},
{
"$ref": "#/components/schemas/DownloadConfirmationRequestDto"
},
{
"$ref": "#/components/schemas/ActivityRequestStepDto"
},
{
"$ref": "#/components/schemas/ActionRequestStepDto"
}
]
},
"ActionRequestStepDto": {
"required": ["description", "stepType", "title"],
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/AbstractRequestStepDto"
},
{
"type": "object",
"properties": {
"actionType": {
"type": "string",
"enum": [
"LIKE",
"VOTING",
"BUYING_NFT",
"SELLING_NFT",
"NFT_OFFER",
"START_FORTUNE_WHEEL",
"OPENING_COLLECTORS_PACK",
"VIDEO_VIEWING",
"REFERRAL_REGISTRATION",
"NEW_LEVEL",
"INSTALLING_EXTERNAL_APPLICATIONS",
"SHARE_BUTTON_CLICK",
"SUBSCRIPTION",
"HOLDING",
"FILLING_PROFILE"
]
},
"actionQuantity": {
"minimum": 1,
"type": "integer",
"format": "int32"
},
"actionSharingType": {
"type": "string",
"enum": [
"POST",
"FALL",
"QUIZ",
"AUCTION",
"TRIAL",
"POLL_RESULTS",
"POLL"
]
},
"actionSharingId": {
"type": "string",
"format": "uuid"
},
"actionProfileParam": {
"type": "array",
"items": {
"type": "string",
"enum": ["EMAIL", "PHONE", "SOCIAL_NETWORK", "WALLET"]
}
},
"actionLevel": {
"type": "integer",
"format": "int32"
}
}
}
]
},
"ActivityRequestStepDto": {
"required": ["description", "stepType", "title"],
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/AbstractRequestStepDto"
},
{
"type": "object",
"properties": {
"activityType": {
"type": "string",
"enum": [
"POLL",
"FEED",
"QUIZ",
"LOOTBOX",
"DONATION",
"CHALLENGE",
"VOTE_NFT"
]
},
"activityId": {
"type": "string",
"format": "uuid"
}
}
}
]
},
"ChallengeRequestDto": {
"required": [
"celebrityId",
"cover",
"description",
"rewards",
"status",
"steps",
"title"
],
"type": "object",
"properties": {
"priority": {
"type": "integer",
"format": "int32"
},
"title": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"description": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"announcement": {
"type": "integer",
"format": "int32"
},
"announcementTime": {
"type": "string",
"format": "date-time"
},
"celebrityId": {
"type": "string",
"format": "uuid"
},
"cover": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"PUBLISHED",
"AWAITING_PUBLICATION",
"DRAFT",
"ARCHIVED",
"DELETED"
]
},
"publishTime": {
"type": "string",
"format": "date-time"
},
"startTime": {
"type": "string",
"format": "date-time"
},
"endTime": {
"type": "string",
"format": "date-time"
},
"rewardType": {
"type": "string",
"enum": ["AUTO", "MANUAL"]
},
"winnersQuantity": {
"type": "integer",
"format": "int32"
},
"steps": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/ActionRequestStepDto"
},
{
"$ref": "#/components/schemas/ActivityRequestStepDto"
},
{
"$ref": "#/components/schemas/DownloadConfirmationRequestDto"
},
{
"$ref": "#/components/schemas/LinkConfirmationRequestDto"
}
]
}
},
"rewards": {
"type": "array",
"items": {
"$ref": "#/components/schemas/RewardRequestDto"
}
}
},
"description": "Challenge Request Dto"
},
"DownloadConfirmationRequestDto": {
"required": ["description", "stepType", "title"],
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/AbstractRequestStepDto"
},
{
"type": "object",
"properties": {
"downloadConfirmation": {
"type": "string"
}
}
}
]
},
"LinkConfirmationRequestDto": {
"required": ["description", "stepType", "title"],
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/AbstractRequestStepDto"
},
{
"type": "object",
"properties": {
"linkConfirmation": {
"type": "string"
}
}
}
]
},
"RewardRequestDto": {
"required": ["awardType", "rewardNumber"],
"type": "object",
"properties": {
"rewardNumber": {
"type": "integer",
"format": "int32"
},
"quantity": {
"type": "integer",
"format": "int32"
},
"collectiblePackType": {
"type": "integer",
"format": "int32"
},
"goldStatusPeriod": {
"type": "string",
"enum": ["SEVEN", "FOURTEEN", "TWENTY_EIGHT"]
},
"awardType": {
"type": "string",
"enum": [
"COINS",
"COLLECTIBLE_PACK",
"NFT",
"SUBSCRIBE",
"FORTUNE_WHEEL",
"CUSTOM"
]
},
"description": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"nftIds": {
"type": "array",
"items": {
"type": "string",
"format": "uuid"
}
}
}
},
"ChallengeResponseDto": {
"required": ["celebrityId", "cover", "description", "status", "title"],
"type": "object",
"properties": {
"priority": {
"type": "integer",
"format": "int32"
},
"title": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"description": {
"maxLength": 1024,
"minLength": 0,
"type": "string"
},
"announcement": {
"type": "integer",
"format": "int32"
},
"announcementTime": {
"type": "string",
"format": "date-time"
},
"celebrityId": {
"type": "string",
"format": "uuid"
},
"cover": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"PUBLISHED",
"AWAITING_PUBLICATION",
"DRAFT",
"ARCHIVED",
"DELETED"
]
},
"publishTime": {
"type": "string",
"format": "date-time"
},
"startTime": {
"type": "string",
"format": "date-time"
},
"endTime": {
"type": "string",
"format": "date-time"
},
"rewardType": {
"type": "string",
"enum": ["AUTO", "MANUAL"]
},
"winnersQuantity": {
"type": "integer",
"format": "int32"
},
"id": {
"type": "string",
"format": "uuid"
}
}
},
"PageChallengeResponseDto": {
"type": "object",
"properties": {
"totalPages": {
"type": "integer",
"format": "int32"
},
"totalElements": {
"type": "integer",
"format": "int64"
},
"size": {
"type": "integer",
"format": "int32"
},
"content": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ChallengeResponseDto"
}
},
"number": {
"type": "integer",
"format": "int32"
},
"sort": {
"$ref": "#/components/schemas/Sort"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"numberOfElements": {
"type": "integer",
"format": "int32"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"empty": {
"type": "boolean"
}
}
},
"PageableObject": {
"type": "object",
"properties": {
"offset": {
"type": "integer",
"format": "int64"
},
"sort": {
"$ref": "#/components/schemas/Sort"
},
"pageSize": {
"type": "integer",
"format": "int32"
},
"pageNumber": {
"type": "integer",
"format": "int32"
},
"paged": {
"type": "boolean"
},
"unpaged": {
"type": "boolean"
}
}
},
"Sort": {
"type": "object",
"properties": {
"empty": {
"type": "boolean"
},
"sorted": {
"type": "boolean"
},
"unsorted": {
"type": "boolean"
}
}
}
},
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment