Skip to content

Commit 4879541

Browse files
committed
Changes report #1773
1 parent c217cd9 commit 4879541

File tree

9 files changed

+1778
-0
lines changed

9 files changed

+1778
-0
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ private void updateResponseSchemaEmbedded(Components components, EntityInfo enti
283283
String newKey = itemsSchema.get$ref() + RESPONSE;
284284
createNewResponseSchema(key, components);
285285
itemsSchema.set$ref(newKey);
286+
updateResponseSchema(key,components.getSchemas().get(key+RESPONSE), components);
286287
}
287288
}
288289
else if (itemsSchema instanceof ComposedSchema) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
24+
package test.org.springdoc.api.app34;
25+
26+
import java.util.Date;
27+
28+
import jakarta.persistence.Entity;
29+
import jakarta.persistence.GeneratedValue;
30+
import jakarta.persistence.GenerationType;
31+
import jakarta.persistence.Id;
32+
import jakarta.persistence.ManyToOne;
33+
import jakarta.persistence.Temporal;
34+
import jakarta.persistence.TemporalType;
35+
36+
37+
@Entity
38+
public class Account {
39+
40+
@Id
41+
@GeneratedValue(strategy = GenerationType.AUTO) private Long id;
42+
43+
@ManyToOne
44+
private Customer customer;
45+
46+
@Temporal(TemporalType.DATE) private Date expiryDate;
47+
48+
public Long getId() {
49+
return id;
50+
}
51+
52+
public Customer getCustomer() {
53+
return customer;
54+
}
55+
56+
public Date getExpiryDate() {
57+
return expiryDate;
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
24+
package test.org.springdoc.api.app34;
25+
26+
27+
import java.util.List;
28+
29+
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
30+
import io.swagger.v3.oas.annotations.tags.Tag;
31+
32+
import org.springframework.data.repository.CrudRepository;
33+
import org.springframework.data.repository.query.Param;
34+
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
35+
36+
/**
37+
* Repository to manage {@link Account} instances.
38+
*
39+
*/
40+
@RepositoryRestResource
41+
@Tag(name = "The account Repository")
42+
@SecurityRequirement(name = "bearer")
43+
public interface AccountRepository extends CrudRepository<Account, Long> {
44+
45+
/**
46+
* Returns all accounts belonging to the given {@link Customer}.
47+
*
48+
* @param customer
49+
* @return
50+
*/
51+
List<Account> findByCustomer(@Param("customer") Customer customer);
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package test.org.springdoc.api.app34;
2+
3+
4+
import java.util.Collection;
5+
6+
import jakarta.persistence.Entity;
7+
import jakarta.persistence.GeneratedValue;
8+
import jakarta.persistence.GenerationType;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.OneToMany;
11+
12+
13+
/**
14+
* @author Oliver Gierke
15+
*/
16+
@Entity
17+
public class Customer {
18+
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.AUTO) private Long id;
21+
22+
private String firstname;
23+
private String lastname;
24+
25+
public Long getId() {
26+
return id;
27+
}
28+
29+
public String getFirstname() {
30+
return firstname;
31+
}
32+
33+
public String getLastname() {
34+
return lastname;
35+
}
36+
37+
@OneToMany(mappedBy = "customer")
38+
private Collection<Account> accounts;
39+
40+
public Collection<Account> getAccounts() {
41+
return accounts;
42+
}
43+
44+
public void setAccounts(Collection<Account> accounts) {
45+
this.accounts = accounts;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
24+
package test.org.springdoc.api.app34;
25+
26+
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
27+
import io.swagger.v3.oas.annotations.tags.Tag;
28+
29+
import org.springframework.data.domain.Page;
30+
import org.springframework.data.domain.Pageable;
31+
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
32+
import org.springframework.data.repository.CrudRepository;
33+
import org.springframework.data.repository.query.Param;
34+
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
35+
import org.springframework.data.rest.core.annotation.RestResource;
36+
37+
/**
38+
* Repository to manage {@link Customer} instances.
39+
*
40+
* @author Oliver Gierke
41+
*/
42+
@RepositoryRestResource
43+
@Tag(name = "The customer Repository")
44+
public interface CustomerRepository extends CrudRepository<Customer, Long>, JpaSpecificationExecutor<Customer> {
45+
46+
/**
47+
* Returns a page of {@link Customer}s with the given lastname.
48+
*
49+
* @param lastname
50+
* @param pageable
51+
* @return
52+
*/
53+
@SecurityRequirement(name = "bearer")
54+
Page<Customer> findByLastname(@Param("lastname") String lastname, Pageable pageable);
55+
56+
@Override
57+
@RestResource(exported = false)
58+
void deleteById(Long id);
59+
60+
@Override
61+
@RestResource(exported = false)
62+
void delete(Customer entity);
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.app34;
20+
21+
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
22+
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
23+
import io.swagger.v3.oas.annotations.info.Info;
24+
import io.swagger.v3.oas.annotations.info.License;
25+
import io.swagger.v3.oas.annotations.security.SecurityScheme;
26+
27+
@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0")))
28+
@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT")
29+
public class OpenApiConfig {
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
24+
package test.org.springdoc.api.app34;
25+
26+
import test.org.springdoc.api.AbstractSpringDocTest;
27+
28+
import org.springframework.boot.autoconfigure.SpringBootApplication;
29+
30+
public class SpringDocApp34Test extends AbstractSpringDocTest {
31+
32+
@SpringBootApplication
33+
static class SpringDocTestApp {}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package test.org.springdoc.api.app34;
2+
3+
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
6+
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
7+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
8+
9+
@Configuration
10+
public class SpringRestConfiguration implements RepositoryRestConfigurer {
11+
@Override
12+
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
13+
config.exposeIdsFor(Account.class, Customer.class);
14+
}
15+
}

0 commit comments

Comments
 (0)