Skip to content

Error in TypeSpec Code: duplicate-property: Model already has a property named #3531

Closed Answered by timotheeguerin
yasu7ri asked this question in Q&A
Discussion options

You must be logged in to vote

Depending on what you exactly want to do here, there is 2 options

import "@typespec/http";

using TypeSpec.Http;

// Option 1 - here you reuse the same property
@route("1/{countryCode}/update") op read1(...Country1): void;

model Country1 {
  @path countryCode: string;
  countryName: string;
}

// Option 2 - here the country is just the body and you still have an explicit path param 
@route("2/{countryCode}/update") op read2(
  @path countryCode: string,
  @body country: Country2,
): void;

model Country2 {
  countryCode: string;
  countryName: string;
}

Playground example

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yasu7ri
Comment options

Answer selected by yasu7ri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants