swagger-api / swagger-api/swagger-codegen

How to generation regex properties as java Map

Open
#11,642 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

How to generation regex properties as java Map
I have regex property "^([OD_]{3}[A-Z]{3}[A-Z_]{4}[0-9_]{3}[0-9999]{8})+$"
and it gen to
@JsonProperty("^([OD_]{3}[A-Z]{3}[A-Z_]{4}[0-9_]{3}[0-9999]{8})+$")
private InlineResponse2002FlightsOriginDestinationInformationOD3AZ3AZ4093099998 _oD3AZ3AZ4093099998$ = null;

Swagger-codegen version
io.swagger.codegen.v3 swagger-codegen-maven-plugin 3.0.32 air generate ./openapi3/services_definitions_v2.0.0.json com.kiu.sys.rest.api.atpco.services_v2 com.kiu.sys.rest.api.atpco.handler.services_v2
			<language>java</language>
			<configOptions>
				<sourceFolder>src/main/java</sourceFolder>
				<hideGenerationTimestamp>true</hideGenerationTimestamp>
				<java8>true</java8>
				<dateLibrary>java8</dateLibrary>
				<interfaceOnly>true</interfaceOnly>
				<library>resttemplate</library>
				<serializableModel>true</serializableModel>
			</configOptions>
		</configuration>
	</execution>
</executions>
Swagger declaration file content or url

"responses": {
"200": {
"description": "The response of get_availability method.",
"content": {
"application/json": {
"examples": {},
"schema": {
"type": "object",
"properties": {
"flights_origin_destination_information": {
"type": "object",
"description": "Description of each origin_destination with date of departure requested by each directionality.",
"properties": {
"^([OD_]{3}[A-Z]{3}[A-Z_]{4}[0-9_]{3}[0-9999]{8})+$": {
"type": "object",
"description": "Dynamic key name reference to origin_destination_reference_key of the object origin_destination_information.",
"example": ["OD_JNBSEZ_02_20210413"],
"properties": {
"arrival_information": {
"type": "object",
"description": "This object hold the point of destination location code.",
"properties": {
"location_reference_id": {"$ref": "#/components/schemas/location_reference_id"}
}
},
"departure_information": {
"type": "object",
"description": "This object holds the point of departure location code",
"properties": {
"location_reference_id": {"$ref": "#/components/schemas/location_reference_id"},
"date": {
"type": "string",
"description": "Date of departure.",
"format": "date"
}
}
}
}
}
}
}
}
}
}
}
}
}

SWG

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Reproduce generation with the supplied Maven configuration and OpenAPI schema, then trace the Java model templates and property handling; done means the regex-keyed object is represented as a Java Map without an invalid mangled property name.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.