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

[Retrieval] Unable to build Location object for /retrieve response #269

Open
anmypapa opened this issue Oct 22, 2024 · 1 comment
Open
Labels
documentation Improvements or additions to documentation

Comments

@anmypapa
Copy link

Problem description

Im using openapi-generator-cli via Docker to generate golang server, but I dont know how to create Location object with this define (generated by openapi-generator-cli):

type Location struct {
	// Last date and time when the device was localized. It must follow RFC 3339 and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)
	LastLocationTime time.Time `json:"lastLocationTime"`
	Area Area `json:"area"`
}

// Area Base schema for all areas
type Area struct {
	AreaType AreaType `json:"areaType"`
}

// Circle Circular area
type Circle struct {
	Area
	Center Point `json:"center"`
	// Distance from the center in meters
	Radius float32 `json:"radius"`
}

// Polygon Polygonal area
type Polygon struct {
	Area
	// List of points defining a polygon
	Boundary []Point `json:"boundary"`
}

Expected action

I want to build Location object which represent Circle or Polygon
Maybe Circle/Polygon is Location's properties instead of Area ??
I'm not sure if there is any problem with location-retrieval.yaml file ???

Additional context

I'm using latest openapi-generator-cli image and yaml file on https://github.com/camaraproject/DeviceLocation/blob/main/code/API_definitions/location-retrieval.yaml

@anmypapa anmypapa added the documentation Improvements or additions to documentation label Oct 22, 2024
@jlurien
Copy link
Collaborator

jlurien commented Nov 18, 2024

Hi @anmypapa,

I think that the OpenAPI spec is correct in the use of inheritance. Area is the base class for both Circle and Polygon classes, and the discriminator areaType helps to identify the child class.

Not sure if there is a problem with the code generator for that specific language. If you identify an error with the use of OpenAPI please report it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants